AndroidStudio SDK開發和APP開發混淆經驗整理
阿新 • • 發佈:2018-11-14
SDK層混淆
SDK開發者不能把你對開發者提供的介面進行混淆混淆
APP層混淆
程式中用到的所有第三方的庫都不能混淆
資料庫操作的對應類也不能混淆
出錯記錄
Error:Execution failed for task ':faceToFace:transformClassesAndResourcesWithProguardForDebug'.
> java.io.IOException: The same input jar [
C:\Users\pactera\Desktop\20160831\FaceToFace\faceToFace\libs\fastjson-1.2.6.jar] is specified twice.
在使用-libraryjars libs/...的時候 就會出現這樣的錯誤,這是應為在android studio中,他已經預設將jar包不進行混淆了,如果你再加入的話就twice了
Error:Execution failed for task ':faceToFace:transformClassesAndResourcesWithProguardForDebug'.
> java.io.IOException: Please correct the above warnings first.
Warning:a.m: can't find referenced class java.nio.file.OpenOption
nio問題是okio混淆了
Warning:u.aly.bt: can't find referenced method 'int checkSelfPermission(java.lang.String)' in library class android.content.Context
程式碼中使用到了檢查許可權的方法
compileSdkVersion 23
編譯環境改為23後
如果使用了httpClient的一些方法,就會出錯
因為Android6.0中移除了httpClient請求網路庫
需要在對應的 build.gradle中的語句塊內新增下面的語句
android {
.....
useLibrary 'org.apache.http.legacy'
}
dependencies {
.......
compile 'org.apache.httpcomponents:httpcore:4.4.2'
}
APP混淆後執行報錯,提示dbutils.find(Contact.class) 裡的Contact類的id欄位找不到
我們的APP程式碼中如果有資料庫操作
就不能混淆這個類
-keep class 包名.domain.Contact { *;}