Android: Proguard not obfuscating code, throwing errors

By : Jasper
Source: Stackoverflow.com
Question!

Here is my configuration:

project.properties:

proguard.config=${sdk.dir}/tools/proguard/proguard-project.txt

# Project target.
target=Google Inc.:Google APIs:22
android.library=false
android.library.reference.1=../../libs/facebook/facebook-android-sdk-4.2.0/facebook

proguard-project.txt: This is empty file i.e everything is commented in it.

The project normally compiles correctly, there are no errors.

When i try to export the apk i see many errors in console (and export fails):

    Proguard returned with error code 1. See console
    Warning: com.facebook.applinks.FacebookAppLinkResolver: can't find superclass or interface bolts.AppLinkResolver
    Warning: com.facebook.applinks.FacebookAppLinkResolver$1: can't find superclass or interface bolts.Continuation
    Warning: org.apache.commons.beanutils.BeanMap$2: can't find superclass or interface org.apache.commons.collections.Transformer
    Warning: org.apache.commons.beanutils.BeanMap$3: can't find superclass or interface org.apache.commons.collections.Transformer
...

But, if i comment out the proguard.config=... line in project.properties, i am able to export successfully without any errors - but the code is not obfuscated.

What am i doing wrong here?

By : Jasper


Answers

When you see warnings while exporting, make sure that all support libraries are available in build path. You can further suppress some warnings and get away with that - see below.

My support jars were getting obfuscated too (not sure if this is normal) resulting in app failing at runtime, so i had to explicitly prevent their obfuscation - see below.

project.properties

proguard.config=/myapp/proguard-project.txt
target=Google Inc.:Google APIs:22
android.library=false
android.library.reference.1=../../pathToLibrary

proguard-project.properties

#To prevent a warning message:
-dontwarn org.ietf.jgss.**

#To prevent supporting jars from getting obfuscated you would need something like:
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class android.** { *; }
By : Jasper


This video can help you solving your question :)
By: admin