Android – Exporting an Android project while using proguard on adt&sdk 20

adtandroidobfuscationproguard

I've updated to the new adt&sdk 20, and I'm having problems with the new way Proguard is being used on Eclipse. I'm not a pro with Proguard at all, yet I've always used it and it worked quite easily. I simply edited the "project.properties" file and added there "proguard.config=proguard.cfg", and it worked.

Sadly, some changes were made that I can't find any information of how to work with them. The official website that talks about Proguard (in the Android website) still talks about the older way.

They wrote on the "project.properties" to uncomment the next line:

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

This didn't work, it gives me these errors when trying to export:

Proguard returned with error code 1. See console
java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
at proguard.shrink.Shrinker.execute(Shrinker.java:159)
at proguard.ProGuard.shrink(ProGuard.java:275)
at proguard.ProGuard.execute(ProGuard.java:101)
at proguard.ProGuard.main(ProGuard.java:492)

Can anyone help me with this? I never had to change the proguard.cfg file before and all was quite automatic. It was very rare that i had to do such a thing.

They also added a file "proguard-project.txt" which probably replaces the proguard.cfg and "extends" from the sdk folder's file, so i wonder: will it be ok to somehow reference to the file in the project instead (and put into the file the content of the "parent" file)? If so, how do I do that?

Best Answer

If it was working fine before and you haven't learnt Proguard, just change this line:

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

to this line:

 proguard.config=proguard.cfg

then you'll have your old Proguard setup back, I'd recommend updating though, it should just work unless your using some 3rd party jars? These are what is it saying is missing and you should use the -keep flag to stop Proguard from removing them when it obfuscates.

Related Topic