API 18的Dagger2 NoClassDefFoundError

时间:2018-10-05 08:22:05

标签: android dagger-2

我的应用程序可以构建/编译,但在运行时仅Android API 18崩溃,在其他版本上我没有问题。

implementation "com.google.dagger:dagger:$daggerLibVer"
annotationProcessor "com.google.dagger:dagger-compiler:$daggerLibVer"
annotationProcessor "com.google.dagger:dagger-android-processor:$daggerLibVer"
implementation "com.google.dagger:dagger-android-support:$daggerLibVer"

库版本为2.16

@Module
public abstract class ActivityBuilder {
    @ContributesAndroidInjector(modules = LoginModule.class)
    abstract LoginActivity bindLogin();

AppClass

@Override
protected AndroidInjector<? extends EfesApplication> applicationInjector() {
    return DaggerApplicationComponent.builder()
            .application(this).create(this);
}

错误日志

10-05 04:14:06.105 3300-3300/com.santsg.efestur E/dalvikvm: Could not find class 'com.santsg.efestur.core.di.components.DaggerApplicationComponent$Builder', referenced from method com.santsg.efestur.core.di.components.DaggerApplicationComponent.builder
10-05 04:14:06.115 3300-3300/com.santsg.efestur E/dalvikvm: Could not find class 'com.santsg.efestur.core.di.components.DaggerApplicationComponent$1', referenced from method com.santsg.efestur.core.di.components.DaggerApplicationComponent.initialize
10-05 04:14:06.135 3300-3300/com.santsg.efestur E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.santsg.efestur.core.di.components.DaggerApplicationComponent$Builder
        at com.santsg.efestur.core.di.components.DaggerApplicationComponent.builder(DaggerApplicationComponent.java:340)
        at com.santsg.efestur.EfesApplication.applicationInjector(EfesApplication.java:61)
        at dagger.android.DaggerApplication.injectIfNecessary(DaggerApplication.java:77)
        at dagger.android.DaggerApplication.onCreate(DaggerApplication.java:53)
        at com.santsg.efestur.EfesApplication.onCreate(EfesApplication.java:40)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4444)
        at android.app.ActivityThread.access$1300(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5103)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

有用的链接NoClassDefFoundError When Using Dagger 2 After Switching to Android Studio 2.0

0 个答案:

没有答案