Monday, 15 March 2010

android - Proguard with AbstractModule -



android - Proguard with AbstractModule -

the next exception beingness thrown when android app starts up;

can't instantiate class com.project.modules.clientservicesmodule; no empty constructor

my module class looks following;

public class clientservicesmodule extends abstractmodule { private context context; public clientservicesmodule(context context) { this.context = context; } @override protected void configure(){ .... bind(new typeliteral<dao<city, integer>>() { }).toprovider(new daoprovider<city, integer>(openhelpermanager.gethelper(context, databasehelper.class).getconnectionsource(), city.class)) .in(singleton.class); ... } }

my proguard file:

-target 1.6 -verbose -dump ../bin/class_files.txt -printseeds ../bin/seeds.txt -printusage ../bin/unused.txt -printmapping ../bin/mapping.txt -optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -ignorewarnings -renamesourcefileattribute sourcefile -keepattributes sourcefile,linenumbertable,*annotation*,signature -dontwarn org.apache.** -dontwarn org.joda.** -dontwarn roboguice.** -dontwarn com.google.** -dontwarn org.slf4j.** -dontwarn twitter.** -dontnote -dontwarn **compathoneycomb # roboguice's jar has testing classes in don't resolve because android testing classes aren't available non-testing -dontwarn roboguice.test.roboactivityunittestcase -dontwarn roboguice.test.robounittestcase -keep public class * extends android.app.activity -keep public class * extends android.app.application -keep public class * extends android.app.service -keep public class * extends android.app.fragment -keep public class * extends android.support.v4.app.fragment -keep public class * extends android.content.broadcastreceiver -keep public class * extends android.content.contentprovider -keep public class * extends android.app.backup.backupagenthelper -keep public class * extends com.google.inject.abstractmodule -keep public class com.android.vending.licensing.ilicensingservice -keep class com.google.inject.** { *; } -keep class javax.inject.** { *; } -keep class javax.annotation.** { *; } -keep class roboguice.** { *; } -keepclasseswithmembers class * { native <methods>; } -keepclasseswithmembers class * { public <init> (android.content.context, android.util.attributeset); } -keepclasseswithmembers class * { public <init> (android.content.context, android.util.attributeset, int); } -keepclassmembers class * implements android.os.parcelable { static android.os.parcelable$creator *; } -keepclassmembers class **.r$* { public static <fields>; } -keepclasseswithmembernames class * { native <methods>; } -keepclassmembers enum * { public static **[] values(); public static ** valueof(java.lang.string); } -keepclassmembers class * extends android.app.activity { public void *(android.view.view); } -keepclassmembers class * { @com.google.inject.inject <init>(...); @com.google.inject.inject <fields>; @javax.annotation.nullable <fields>; } -keepclassmembers class * { void *(net.eworldui.videouploader.events.*); } -keepclassmembers class * { void *(roboguice.activity.event.*); }

my proguard config works if add together empty constructor dao wont load null beingness passed database helper.

if remove proguard step pom.xml works expected.

the question how enable proguard module class can startup context beingness passed in.

thank you.

try add together next line proguard.config:

-keep public class * extends com.project.modules.clientservicesmodule { <fields>; <methods>; }

and see if error persists

edit:

you can maintain whole namespace defining:

-keep class com.project.modules.** {*;}

if works, can seek exclude others don't need after that. have @ first edit, too

android maven module proguard

No comments:

Post a Comment