Running an obfuscated version of my application throws the following stacktrace
java.lang.RuntimeException: Unable to create service com.mycompany.myapp.async.alarms.AlarmIntentService: java.lang.IllegalStateException: Errors creating object graph:
dagger.Lazy could not be bound with key dagger.Lazy required by dagger.Lazy com.mycompany.scheduler.c.mNotificationDisplayer
If I add -dontobfuscate, it runs smoothly
Here's the class that contains that field
public abstract class AbstractAlarmSchedulerService extends IntentService {
@Inject
Lazy<AbstractAlarmSchedulerNotificationDisplayer> mNotificationDisplayer;
I extend from this class in my application, but it belongs to an external library.
These are my dagger proguard rules, copied from https://stackoverflow.com/a/18177491/218473
#Dagger
-keepattributes *Annotation*
-keepclassmembers,allowobfuscation class * {
@javax.inject.* *;
@dagger.* *;
<init>();
}
-keep class * extends dagger.internal.Binding
-keep class * extends dagger.internal.ModuleAdapter
-keep class **$$ModuleAdapter
-keep class **$$InjectAdapter
-keep class **$$StaticInjection
-keep class dagger.* { *; }
-keep class javax.inject.* { *; }
-keep class * extends dagger.internal.Binding
-keep class * extends dagger.internal.ModuleAdapter
-keep class * extends dagger.internal.StaticInjection
-keep !abstract class com.mycompany.** { *; }
-keepnames class dagger.Lazy
I've tried keeping all classes and all members to see if that fixed anything, but the error persisted
-keep class * { *; }
com.mycompany.scheduler is an external library, while com.mycompany.myapp contains the source for the actual application.
In case it's needed, here's the Module I'm using
@Module(injects = {AlarmIntentService.class, ReminderNotificationDisplayer.class, AlarmsBroadcastReceiver.class})
public class AndroidModule {
private final AbstractMyApplication application;
public AndroidModule(AbstractMyApplication application) {
this.application = application;
}
/**
* Allow the application context to be injected
*/
@Provides @Singleton
Context provideApplicationContext() {
return application;
}
@Provides
public AlarmManager provideAlarmManager(Context context){
return (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
}
@Provides
@Singleton
public NotificationManager provideNotificationManager(Context context){
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
}
@Provides
@Singleton
public AbstractAlarmSchedulerNotificationDisplayer provideNotificationDisplayer() {
return new ReminderNotificationDisplayer();
}
}
I'm using dagger & dagger-compiler 1.2.+ dependencies
Thanks!