解決方案:Cannot resolve symbol xxx Android Studio 3.1.4

最近更新了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包有問題就把該配置註釋掉,比如下面這個:
2.點擊Sync Now

3.然後解開註釋

4.再點擊Sync Now

好吧有人說這個按鈕找不到,我貼個圖吧
在這裏插入圖片描述
再補一張動圖
在這裏插入圖片描述
5.問題解決.世界安好

 

其他解決方案一:

這裏寫圖片描述

這裏寫圖片描述

其他解決方案二:

這裏寫圖片描述

其他解決方案三:

這裏寫圖片描述
解決方案,修改版本

完整修改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.問題解決.世界安好
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章