1. 程式人生 > >Android Studio升級過程中可能出現的錯誤

Android Studio升級過程中可能出現的錯誤

1.gradle編譯完後出現了幾百個error
特別是Ingoring InnerClasser attribute for an anonymous inner class這個錯誤,擷取錯誤提示的一部分

Warning:Ignoring InnerClasses attribute for an anonymous inner class
this warning is that reflective operations on this class will incorrectly
Warning:Ignoring InnerClasses attribute for an anonymous inner class
associated EnclosingMethod attribute. This class was probably produced by a solution is to recompile the class from source, using an up-to-date compiler compiler that did not target the modern .class file format. The recommended

很驗證去判斷到底是什麼,只知道是complie的時候出問題,排查了一下,發現原因是重複導包
解決辦法是:去gradle裡面移除重複的jar包

比如我的gradle裡面就有

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.facebook.fresco:fresco:0.6.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    // 下面這個就是重複的包,因為這個包已經在libs資料夾下,而libs資料夾是我們已經在最開始的時候通過compile fileTree匯入進來了,所以下面這句需要刪除
compile files('libs/umeng-update-v2.6.0.1.jar')

刪除了最後一句 compile files(‘libs/umeng-update-v2.6.0.1.jar’)後,真機執行正常。

2.gradle的版本升級問題
每次更新Android Studio,都會提示更新gradle,最好的方式就是科學上網,在Android Studio內更新。實在不行的話,就自己去AndroidDevTools下載相應的gradle,本地更新。