无法访问ActivityCompatApi23的ActivityCompatApi23类文件 [英] cannot access ActivityCompatApi23 class file for ActivityCompatApi23 not found

查看:203
本文介绍了无法访问ActivityCompatApi23的ActivityCompatApi23类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中添加了一个信号库,突然我运行该项目时,我的代码中出现了很多错误,其中最重要的是

Hi i added one signal libraries in to my project and suddenly when i run the project a lots of error shows up in my code which in top is

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'

推荐答案

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

You are using different versions for support libraries

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来解决问题.像这样

So when gradle tries to build your project, it finds two different support library versions.

I guess you can fix your problem with upgrading all your support libraries to version 27.1.1. Like this

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. +',因为它会引起类似这样的问题,因此不建议使用.我猜想Android Studio本身在使用'X. +'添加依赖项时会显示警告.

Also, as parekhkruti26 said in comments, never use 'X.+' for versions since it can cause problems like this and its not recommended. I guess android studio itself shows a warning when adding dependencies using 'X.+'.

这篇关于无法访问ActivityCompatApi23的ActivityCompatApi23类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆