2017-03-09 70 views
0

我在我的項目中使用multidex enabled。當我使用minifyEnabled真正我得到這個錯誤如何使安全簽名的apk很難逆向工程?

FAILURE: Build failed with an exception. 
  • 出了什麼問題: 執行失敗的任務 ':應用程序:transformClassesAndResourcesWithProguardForRelease'。

    作業失敗,詳見

    日誌

這裏是我的gradle這個文件:

 apply plugin: 'com.android.application' 

    android { 
     compileSdkVersion 25 
     buildToolsVersion "25.0.2" 
     useLibrary 'org.apache.http.legacy' 
     defaultConfig { 
      applicationId "com.app.example" 
      minSdkVersion 15 
      targetSdkVersion 25 
      versionCode 9 
      versionName "1.8" 
      multiDexEnabled true 


     } 
     buildTypes { 
      release { 
       minifyEnabled true 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
      } 
     } 
     dexOptions { 
      preDexLibraries = false 
     } 
     productFlavors { 
     } 

     lintOptions { 
      checkReleaseBuilds false 
     } 
    } 


    repositories { 

     maven { 
      url 'https://dl.bintray.com/ayz4sci/maven/' 
     } 

    } 

    dependencies { 
     compile fileTree(include: ['*.jar'], dir: 'libs') 
     testCompile 'junit:junit:4.12' 
     compile 'com.android.support:design:25.1.1' 
     compile 'com.android.support:appcompat-v7:25.1.1' 
     compile 'com.android.support:multidex:1.0.1' 


    } 

UPDATE(看到日誌由凱文的建議後

  • 我添加此行dontwarn

    -dontwarn com.squareup.picasso.** 
    -dontwarn com.vungle.** 
    -dontwarn twitter4j.** 
    

其工作,但我使用d-MAX /點,對話和不顯示簽字後的apk

它也使用-keep類來解決。

回答

3

如果使用縮小,默認情況下啓用了代碼混淆..

它還刪除未使用的方法。我使用谷歌支持庫的20k +方法,當我使用minify時,它減少到大約5k左右..所以你必須修改你的應用的proguard-rules,告訴代碼混淆器不要刪除你的類。

例如:

-keep class com.app.example.** {*;} 
-dontwarn com.app.example.** 

# Ensure annotations are kept for runtime use. 
-keepattributes *Annotation* 
# Don't remove any GreenRobot classes 
-keepnames class org.greenrobot.** {*;} 
# Don't remove any methods that have the @Subscribe annotation 
-keepclassmembers class ** { 
    @de.greenrobot.event.Subscribe <methods>; 
} 

你可以找到哪個類是通過讀取錯誤日誌需要,它通常說的東西線「需要類X,但沒有發現」

+1

**我發現只有這樣:**警告:異常處理任務java.io.FileNotFoundException:D:\ workspace \ Appname \ app \ build \ intermediates \ proguard-rules \ release \ aapt_rules.txt(系統找不到指定的路徑) –

+1

@ bdevloper嗯嘗試在你的gradle中只使用'proguardFiles getDefaultProguardFile('proguard-android.txt')',並且它還說找不到proguard文件,所以ch eck目錄是否存在 –

+0

意思是如果我不使用minifyEnabled我的apk的gradle逆向工程很難嗎? –