首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Android:编译错误:任务':app:compileDebugJava‘执行失败

Android:编译错误:任务':app:compileDebugJava‘执行失败
EN

Stack Overflow用户
提问于 2015-12-28 13:54:33
回答 3查看 26.5K关注 0票数 3

我面临以下错误:

代码语言:javascript
复制
Error:(89, 39) error: incomparable types: CAP#1 and int  
where CAP#1 is a fresh type-variable:  
CAP#1 extends Object from capture of ?Note: Some input files use unchecked or   unsafe operations.  
Note: Recompile with -Xlint:unchecked for details.  
Error:Execution failed for task ':app:compileDebugJava'.  

编译失败;有关详细信息,请参阅编译器错误输出。

我的Gradle文件如下所示:

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0 rc3"

    repositories {
        maven { url "https://jitpack.io" }
        mavenCentral()
        jcenter()

    }

    defaultConfig {
        applicationId "wishlist.oj.app"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:21.+'
    compile 'com.android.support:cardview-v7:21.+'
}

错误来自我的回收器视图适配器文件,它只是将多堆文本视图膨胀为回收器视图

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-12-28 13:56:38

错误:任务':app:compileDebugJava‘执行失败。

为了更好的实践

首先启用multiDexEnabled,然后升级您的support:recyclerviewsupport:appcompatsupport:cardview版本

是Android SDK Build Tools 21.1及更高版本中提供的Android plugin for Gradle,它在构建配置中支持multidex。在尝试为您的应用程序配置multidex之前,请确保使用SDK管理器将Android SDK构建工具工具和Android支持存储库更新为最新版本。

要将应用程序开发项目设置为使用multidex配置,您需要对应用程序开发项目进行一些修改。特别是,您需要执行以下步骤:

  1. Change您的Gradle build配置以启用multidex
  2. Modify您的清单以引用MultiDexApplication class

修改您的应用程序Gradle构建文件配置,以包含支持库并启用多索引输出。

代码语言:javascript
复制
     android {
        compileSdkVersion 23
        buildToolsVersion "23.0.1"

        defaultConfig {
            ...
            minSdkVersion 16
            targetSdkVersion 23
            ...

            // Enabling multidex support.
            multiDexEnabled true
        }
        ...
    }

    dependencies {
      compile 'com.android.support:multidex:1.0.0'
      compile 'com.android.support:appcompat-v7:23.1.1'
      compile 'com.android.support:recyclerview-v7:23.1.1"
      compile 'com.android.support:cardview-v7:23.1.1'
     }

然后Clean-Rebuild-Restart-Sync你的项目

票数 5
EN

Stack Overflow用户

发布于 2015-12-28 13:56:29

变化

代码语言:javascript
复制
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1"
compile 'com.android.support:cardview-v7:23.1.1'
票数 2
EN

Stack Overflow用户

发布于 2020-05-14 18:24:49

只需添加。

代码语言:javascript
复制
android:{
 lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34488349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档