无法访问找不到ActivityComptApi23的ActivityCompeApi23类文件



嗨,我在我的项目中添加了一个信号库,当我运行项目时,我的代码中突然出现了很多错误,最上面的是

Error:(66, 8) error: cannot access ActivityCompatApi23
class file for android.support.v4.app.ActivityCompatApi23 not found

这是我的代理人

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:26.0.0-alpha1'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.github.lzyzsd:circleprogress:1.1.0@aar'
compile 'com.github.clans:fab:1.6.2'
compile 'se.emilsjolander:StickyScrollViewItems:1.1.0'
compile 'se.emilsjolander:stickylistheaders:2.1.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.hashids:hashids:1.0.1'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
compile 'com.google.android.gms:play-services-drive:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.onesignal:OneSignal:3.+@aar'
compile 'com.google.android.gms:play-services-gcm:10.2.1'
compile "com.google.android.gms:play-services-location:10.2.1"
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
compile 'com.adjust.sdk:adjust-android:4.12.0'
compile 'com.android.installreferrer:installreferrer:1.0'

您正在使用不同版本的支持库

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:26.0.0-alpha1' <- here you are compiling 26.0.0-alpha1
// ...
compile 'com.android.support:appcompat-v7:26.+'
// ...
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:26.+' <- this one can be different from 26.0.0-alpha1 since it compiles versions greater than 26, i.e. version 27.1.1
compile 'com.android.support:design:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support:cardview-v7:26.+'
// ...

因此,当gradle试图构建您的项目时,它会发现两个不同的支持库版本。

我想您可以通过将所有支持库升级到27.1.1版本来解决问题。像这个

compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:27.1.1'
// ...
compile 'com.android.support:appcompat-v27.1.1'
// ..
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
// ...

此外,正如parekhkruti26在评论中所说,永远不要使用"X.+"对于版本,因为它可能会导致这样的问题,不推荐使用。我想安卓工作室本身在使用"X.+"添加依赖项时会显示警告。

相关内容

  • 没有找到相关文章

最新更新