user2847219
user2847219

Reputation: 555

Android studio proguard error

I enabled proguard to obfuscate the code of my application. Specifically, I would only obscure the activity of the application, but I get a lot of mistakes when creating the APK. This error also arises if imposed proguard true in libraries. Can anyone help me ?

    apply plugin: 'com.android.application'    

android {         
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "my.packname"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 52
        versionName "2.0.2"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/commons-codec-1.8.jar')
    compile files('libs/dropbox-android-sdk-1.6.3.jar')
    compile files('libs/httpmime-4.0.3.jar')
    compile files('libs/json_simple-1.1.jar')
    compile files('libs/pass-v1.2.1.jar')
    compile files('libs/sdk-v1.0.0.jar')    
    compile project(':library_edittext')
    compile project(':aFileChooser')
    compile project(':library_color_picker')
    compile project(':sqlcipher-for-android')
    compile project(':library_menu_main')
    compile 'io.reactivex:rxjava:1.0.10'    
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
 }

error:

 Warning:there were 87 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
:app:transformClassesAndResourcesWithProguardForRelease FAILED
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

     Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
    > java.io.IOException: Please correct the above warnings first.

Upvotes: 0

Views: 2739

Answers (1)

Bruce
Bruce

Reputation: 326

As the error message suggests, if the app is running ok, you can use --dontwarn, etc in your proguard file. Like this:

-dontwarn android.support.**
-dontnote android.support.**

If you are having issues, you will have to delve a bit into why.

For instance, how it is optimized, etc.

-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable

-keepparameternames
-keepattributes Signature,Exceptions,InnerClasses,Deprecated,
                SourceFile,LineNumberTable,EnclosingMethod,
                *Annotation*

Here is an android reference: https://developer.android.com/studio/build/shrink-code.html

Many libraries also have the proguard info for their library which is most helpful.

Upvotes: 2

Related Questions