How to make works cordova-based app with ProGuard

421 views Asked by At

Im trying to build cordova-based app with obfuscation enabled.
IBM MobileFirst Platform Foundation version is 7.1.0.00.20151227-1730.

My steps:
- create new classic mfp project (used as environment runtime)
- create new mfp cordova project with Android Env (used as client app)
- push new client app to environment
- uncomment proguard.config option in project.properties
- add proper keystore configuration in project.properties - configure app for release
- run ant release as usual

Output: I get huge amount of warnings
[proguard] Note: duplicate definition of program class ...

Then build failes
[proguard] Warning: there were 1 unresolved references to program class members. [proguard] Your input classes appear to be inconsistent. [proguard] You may need to recompile them and try again. [proguard] Alternatively, you may have to specify the option [proguard] '-dontskipnonpubliclibraryclassmembers'. BUILD FAILED

And this is on newly created project. Nothing changed. Just added keystore.

How should I properly configure ProGuard?

1

There are 1 answers

0
robert On

The problem in your case has to do with classes that have package private access modifiers on fields or methods. These get obfuscated by default. Thus the warning "Warning: there were 1 unresolved references to program class members."

As suggested you could use -dontskipnonpubliclibraryclassmembers in proguard-project.txt (see below). For details on this and other config parameters, check http://proguard.sourceforge.net/manual/usage.html

Change android/proguard configuration in proguard-project.txt (see http://tools.android.com/recent/proguardimprovements)