使用android studio混淆過程中遇到的異常

1.dexDebug ExecException finished with non-zero exit value 2
需要在gradle中配置下面的代碼,原因是引用了多個libraries文件




defaultConfig {
        multiDexEnabled true
}




2.Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/app/BackStackState$1.class




原因:在所添加的jar包或aar包中也引用了support-V4,與工程中引用的相沖突
Ctrl+N --> 在搜索框中輸入BackStackState --> 查找到所有引用該類的類,這些類即爲引起衝突的類
去掉本工程中gradle中用於引用有衝突的包的代碼或者將衝突的代碼從jar包或aar包中移除,確保一個module中只引用了一份相同的第三方包




3.project sturcture和Project Structure 無論是按快捷鍵或者是從files中打開都不顯示




event log中報:IllegalArgumentException:Multiple entries with same key: Google Inc.:Google APIs:23=Google APIs (Google Inc.) (API 23) and Google Inc.:Google APIs:23=Google APIs (Google Inc.) (API 23)




解決辦法:先看一下系統配置的SDK的位置和Android Studio所用的路徑是否一致,如果不一致重新配置系統的SDK路徑或者是重新修改Android Studio的SDK路徑
通過SDK Manager刪除掉google API23
如果解決不了,卸載android studio -->重新安裝 ,還有問題點擊File --> Invalidate Cashes/Restart --> Invalidate and Restart,解決不了繼續通過SDK Manager刪除掉google API23




4.如果依賴工程和主工程中有同名同類型的資源文件,需要修改依賴工程中的資源名稱編譯時纔不會報錯,如果依賴工程中的這個資源文件是整個工程都不需要用到的,可以直接刪掉;




5..Logcat的console中,顯示”no debuggable applications”的問題:Tools→Android→Enable ADB Integration;


6.移除所有support-v4的依賴
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}


6.14.Execution failed for task ':xxx:validateRelealseSigning'.
> Keystore file E:\code\xxxr\xxx_keystore not found for signing config 'relealse'.




build.gradle目錄中的配置內容爲
 //簽名
    signingConfigs {




        relealse {
            storeFile file("../xxx_keystore")




            storePassword "xxx"
            keyAlias "xxx"
            keyPassword "xxx"
        }
    }








../xxx_keystore指的是該工程所在的工作空間目錄,在具體工程目錄的上一級,如果文件位置放錯會導致找不到文件


7.出現下面的異常時




Error:Execution failed for task ':xxx:transformClassesAndResourcesWithProguardForRelease'.
> java.io.FileNotFoundException: E:\testimportintostudio\xxx\proguard.cfg (系統找不到指定的文件。)


從eclipse中導出的gradle工程,會報這個錯誤
一種方式可以將eclipse中的proguard.cfg這個文件拷貝到所提示的目錄中
另一種方式可以將Module中的build.gradle中的混淆編譯代碼改爲

//加載默認混淆配置文件
//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'


改爲
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'




8.導包時報錯This fragment should provide a default constructor,
忽略錯誤
lintOptions { 
  abortOnError false 
  checkReleaseBuilds false 





9.從eclipse中導出的工程在android studio中亂碼
下載超級批量轉碼轉換 --> 將所要轉碼的文件所在的文件夾拖到工具中 -- >不管原來是什麼編碼,將編碼方式複選框中選中你所要轉換的編碼格式-->點擊開始

注:轉碼之前將代碼複製一份,因爲偶爾有個別文件在轉碼過程中出現異常,代碼只剩下一半的問題,需將原來的代碼拷貝過去



10.E:\MyApplication3\app\build\intermediates\res\merged\apus\debug\values-v23\values-v23.xml
Error:(4) Error retrieving parent for item: No resource found that matches the given name 


'Android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(33) Error retrieving parent for item: No resource found that matches the given name 


'android:Widget.Material.Button.Colored'.


編譯時所需要的資源文件所需要的SDK版本是23,將編譯的版本改爲23就可以了  compileSdkVersion 23

發佈了116 篇原創文章 · 獲贊 30 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章