无法使用proguard生成签名的apk

时间:2016-10-10 20:35:04

标签: android google-play-services proguard android-multidex signed-apk

当我尝试生成已启用proguard的已签名apk时,我收到以下错误。

Object

这就是我正在使用/做的事情:

  1. Android studio 2.2
  2. play-services version 9.6.1
  3. proguard-rules.pro

    • Error:Uncaught translation error: com.android.dx.cf.code.SimException: com.android.dx.rop.cst.CstMethodRef cannot be cast to com.android.dx.rop.cst.CstInterfaceMethodRef Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) <a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. <a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
    • dontwarn okio.
    • dontwarn retrofit2.Platform$Java8
    • keep public class com.google.android.gms.
    • dontwarn com.google.android.gms.
  4. 的gradle(APP)

    keepattributes InnerClasses,EnclosingMethod
  5. 我正在使用的图书馆:

    • defaultConfig { applicationId "com.something.something" minSdkVersion 15 targetSdkVersion 23 versionCode 3 versionName "3.0" // Enabling multidex support. multiDexEnabled true testInstrumentationRunner "com.android.test.runner.MultiDexTestRunner" } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } productFlavors { }
    • com.radiusnetworks:proximitykit-android:0.+@aar
    • com.squareup.retrofit2:retrofit:2.0.2

1 个答案:

答案 0 :(得分:0)

根据此SO answer,只要您不需要任何特殊的ProGuard配置,下面的代码就可以运行。

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt')
    }
}
     

如果您这样做,请使用原始proguardFiles条目并创建文件/Users/franek/Documents/Android_Studio_Melange/app/proguard-rules.txt,然后将自定义规则放入此文件中。

thread也可能有所帮助。将以下行添加到proguard-rules.pro文件,以解决无法使用Proguard (Minify Enabled = true)生成已签名APK的问题。

  

保持课程org.apache.http。**
  保持类android.net.http。**
  dontwarn com.google.android.gms。**