Search code examples
androidproguard

How to use -dontwarn in ProGuard?


I am using android studio to build debug and release application. When i build debug/release application

./gradlew assembleDebug

./gradlew assembleRelease

both build are created perfectly and run as well. Shows appropriate dialog box for debug or release

now i have added proguard details in build.gradle:

signingConfigs {
    myConfig {
           storeFile file("keystore.jks")
           storePassword "abc123!"
           keyAlias "androidreleasekey"
           keyPassword "pqrs123!"
    }
}

buildTypes {
    release {
        runProguard true
        proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        signingConfig signingConfigs.myConfig
    }
}
productFlavors {
    defaultFlavor {
        proguardFile 'proguard-rules.txt'
    }
}

Now it shows error in event log as

Warning: there were 7 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: there were 2 unresolved references to program class members. Your input classes appear to be inconsistent. You may need to recompile the code.

(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember) :Flash Sales:proguardDefaultFlavorRelease FAILED

If i turn the runProguard option to false then its running.

I have these questions:

1) is it ok to release apk with runProguard = false?

2) How to use dontwarn while creating release build?


Solution

  • When I add new lib to project Generally this How I need to define for Progaurd.

    Let's say I am using Twitter4J lib then I add dontwarn this way.

    -keep class twitter4j.** { *; }

    -dontwarn twitter4j.**