当我的 android 应用程序启动时引发以下异常;
can't instantiate class com.project.modules.ClientServicesModule; no empty constructor
我的模块类如下所示;
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);
...
}
}
我的 Proguard 文件:
-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 it which don't resolve because the Android testing classes aren't available for 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.*);
}
如果我添加一个空的构造函数,我的 ProGuard 配置可以工作,但是 dao 不会加载,因为 null 被传递到数据库帮助程序中。
如果我从 pom.xml 中删除 ProGuard 步骤,一切都会按预期工作。
问题是如何启用 proguard 以便模块类可以在传入的上下文中启动。
谢谢你。