gpt4 book ai didi

android - 无法加载类的模块适配器。请确保已为此模块运行代码生成

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:52:01 24 4
gpt4 key购买 nike

当我尝试运行我的应用程序时出现此错误:

E/AndroidRuntime(2314): java.lang.RuntimeException: 
Unable to create application in.mubble.billbytwo.GlobalApp:
java.lang.IllegalStateException: Module adapter for class
in.mubble.billbytwo.RootModule could not be loaded.
Please ensure that code generation was run for this module.

我想我正在使用基于 Ant 的构建系统,但我不确定,这是我的第一个 Dagger 项目,我在 Eclipse IDE 上。

PS:我已经尝试将 java-writer 和 dagger-compiler 添加到工厂路径中作为一些 other帖子建议但没有运气。

这是一个完整的堆栈跟踪:

FATAL EXCEPTION: main
Process: in.mubble.billbytwo, PID: 2314
java.lang.RuntimeException:
Unable to create application in.mubble.billbytwo.GlobalApp:
java.lang.IllegalStateException: Module adapter for class
in.mubble.billbytwo.RootModule could not be loaded.
Please ensure that code generation was run for this module.

at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4347)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller
.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)

Caused by: java.lang.IllegalStateException:
Module adapter for class
in.mubble.billbytwo.RootModule could not be loaded.
Please ensure that code generation was run for this module.
at dagger.internal.FailoverLoader$1.create(FailoverLoader.java:45)
at dagger.internal.FailoverLoader$1.create(FailoverLoader.java:40)
at dagger.internal.Memoizer.get(Memoizer.java:56)
at dagger.internal.FailoverLoader.getModuleAdapter(FailoverLoader.java:57)
at dagger.internal.Modules.loadModules(Modules.java:43)
at dagger.ObjectGraph$DaggerObjectGraph.makeGraph(ObjectGraph.java:174)
at dagger.ObjectGraph$DaggerObjectGraph.access$000(ObjectGraph.java:138)
at dagger.ObjectGraph.create(ObjectGraph.java:129)
at in.mubble.billbytwo.Injector.init(Injector.java:13)
at in.mubble.billbytwo.Injector.init(Injector.java:24)
at in.mubble.billbytwo.GlobalApp.onCreate(GlobalApp.java:67)
at android.app.Instrumentation
.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4344)

请帮助解决这个问题。

最佳答案

重要的是要确定代码生成正在发生。检查您的构建目录以确保实际生成了此类。我没有将 Ant 与 Dagger 一起使用,但您肯定需要确保 dagger-compiler-${version}.jar 可用于 javac,因此请检查您的类文件夹并查看代码是否正在生成。如果不是,则为构建配置问题。

如果是,那么您需要检查混淆器配置并确保它保留了从 ModuleAdapter 和 Binding 继承的所有内容。这是至关重要的,因为 Dagger 1.x 动态加载适配器,因此代码中没有静态依赖项可以通知 Proguard 不理会它。因此,Proguard 可能只是删除了适配器代码,因此 Dagger 无法加载它。

(注意,这个问题会在Dagger 2中消除)

关于android - 无法加载类的模块适配器。请确保已为此模块运行代码生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23653421/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com