4

I'm getting the following error when I'm trying to generate a signed apk with proguard enabled.

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.

This is what I'm using/doing:

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

    • dontwarn okio.
    • dontwarn retrofit2.Platform$Java8
    • keep public class com.google.android.gms.
    • dontwarn com.google.android.gms.
    • keepattributes InnerClasses,EnclosingMethod
  4. gradle(app)

    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 {
    }
    
  5. Libraries that I'm using:

    • com.radiusnetworks:proximitykit-android:0.+@aar
    • com.squareup.retrofit2:retrofit:2.0.2
    • com.google.firebase:firebase-messaging:9.6.1
Mr.Rebot
  • 6,703
  • 2
  • 16
  • 91
Roehit Kadam
  • 101
  • 1
  • 11

1 Answers1

0

Based from this SO answer, the code below should work as long as you don't need any special ProGuard configuration.

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

If you do, use your original proguardFiles entry and create the file /Users/franek/Documents/Android_Studio_Melange/app/proguard-rules.txt then put your custom rules in this file.

This thread might also help. Add the following lines to the proguard-rules.pro file to resolve the issue of being unable to generate a signed APK using Proguard (Minify Enabled = true).

keep class org.apache.http.**
keep class android.net.http.**
dontwarn com.google.android.gms.**

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59