我遇到了以下错误:
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'.
Compilation failed; see the compiler error output for details.
我的 Gradle 文件如下所示:
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.+'
}
错误来 self 的 Recycler View Adapter 文件,它只是将 multiple textviews 膨胀到 recycler view
最佳答案
Error:Execution failed for task ':app:compileDebugJava'.
良好实践
首先启用multiDexEnabled
,然后升级你的support:recyclerview
,support:appcompat
,support:cardview
版本
The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android Support Repository to the latest version using the SDK Manager before attempting to configure your app for multidex.
将您的应用开发项目设置为使用 multidex 配置需要您对应用开发项目进行一些修改。特别是您需要执行以下步骤:
- 更改 Gradle 构建配置以启用 multidex
- 修改 list 以引用 MultiDexApplication 类
修改您的应用 Gradle 构建文件配置以包含支持库并启用 multidex 输出。
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你的项目
关于Android:编译错误:任务 ':app:compileDebugJava'执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34488349/