android - Proguard causing NoSuchMethodException -


class<?> c = class.forname("co.uk.myapp.dir.targetclass"); method main = c.getdeclaredmethod("main", report_holder.class); 

throws 'java.lang.nosuchmethodexception.main[class co.uk.myapp.classes.report_holder]' error once i've prepared app release using proguard.

i spent hours thinking problem in 'co.uk.myapp.dir.targetclass', commenting out things, re-releasing app, , re-testing. turns out error right @ root, at:

method main = c.getdeclaredmethod("main", report_holder.class); 

i updated proguard-project.txt include:

-dontobfuscate -keeppackagenames 

(i using lint suggested method suggested putting code project.properties , putting config in text file), such as:

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

but adding 2 lines didn't have effect.

so wondering if;

a) should add on top of '-keeppackagenames' etc.

b) proguard.config set correctly; should ${sdk.dir} proper uri sdk

the class targeting this:

public static void main(report_holder args) { .... } 

edit

or because have 2 instances of type of thing, both called 'main' ? called in different activities.

method main = c.getdeclaredmethod("main", report_holder.class); method main = c.getdeclaredmethod("main", otherreport_holder.class); 

and both targets being this:

public static void main(report_holder args) { .... }  public static void main(otherreport_holder args) { .... } 

once know how use proguard, should add option -keepattributes signature . necesary when using generics (collections).

for methods beeing called via reflection, must explictly exclude them obfsucation. use option output obfuscation map file, see if rules had desired effect.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -