真正解决方案:Cannot resolve symbol 'xxx' (Android(安卓)Studio 3.1.4)
16lz
2021-01-24
最近更新了Android Studio 到最新版本3.1.4,但是却出现了一个问题,
Cannot resolve symbol ‘Theme’ in styles.xml (Android Studio)
Failed to load AppCompat ActionBar with unknown error.
Cannot resolve symbol ‘OkhttpUtils’
…
有时候会出现类似theme主题找不到,甚至AppCompatActivity 这个类也找不到,
更严重有时候引入的所有Github 上的类库都找不到了,都快要吐血崩溃了。
好在经过 一番苦战,终于摸清楚了脾气,找到了终极解决方案。
终极解决方案:
1.哪个Jar包有问题就把该配置注释掉,比如下面这个:
dependencies { //implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' //implementation 'com.android.support:design:28.0.0-alpha3' //implementation 'com.android.support:support-v4:28.0.0-alpha3' //implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'}
2.点击Sync Now
3.然后解开注释
dependencies { implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' implementation 'com.android.support:design:28.0.0-alpha3' implementation 'com.android.support:support-v4:28.0.0-alpha3' implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'}
4.再点击Sync Now
5.问题解决.世界安好
其他解决方案一:
其他解决方案二:
其他解决方案三:
解决方案,修改版本
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
为
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
完整修改build.gradle内容如下:
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0-alpha1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:28.0.0-alpha1' implementation 'com.android.support:support-v4:28.0.0-alpha1' implementation 'com.android.support:recyclerview-v7:28.0.0-alpha1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}
参考地址:After Updating Android studio to 3.1.2 , I get “Failed to load AppCompat ActionBar with unknown error. ”
其他解决方案四:
也有可能是jar包因为网络原因没下载更新好。。。
删除这个文件夹下的所有jar,或者找到没识别的jar删除再重新下载
/Users/(用户名)/.gradle/
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { google() jcenter() maven { url 'https://jitpack.io' } }}
其他解决方案五:
1.哪个Jar包有问题就把该配置注释掉,比如下面这个:
dependencies { //implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' //implementation 'com.android.support:design:28.0.0-alpha3' //implementation 'com.android.support:support-v4:28.0.0-alpha3' //implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'}
2.点击Sync Now
3.然后解开注释
dependencies { implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' implementation 'com.android.support:design:28.0.0-alpha3' implementation 'com.android.support:support-v4:28.0.0-alpha3' implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'}
4.再点击Sync Now
5.问题解决.世界安好
更多相关文章
- Execution failed for task ':app:transformClassesWithNewClass
- Android(安卓)SystemService类注释
- ANDROID 自动接听 支持2.3以上版本
- 关于android各种双卡手机获取imei,imsi的处置(mtk,展讯,高通等)
- [置顶] Android获取本地图片缩略图终极解决方案
- Android编译错误:You have tried to change the API from what ha
- Android进程守护详解及解决方案
- android SQLite存储简单范例+详细注释(增删查改)
- Android使用真机无法调试,抱错INSTALL_FAILED_INSUFFICIENT_STOR