Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

AndroidAnnotations with dagger compile error #631

Closed
sinojelly opened this issue Jun 16, 2013 · 10 comments
Closed

AndroidAnnotations with dagger compile error #631

sinojelly opened this issue Jun 16, 2013 · 10 comments

Comments

@sinojelly
Copy link

The code is here:
git clone git@github.com:sinojelly/androidannotations-dagger-example.git -b master

run command:
maven install

got error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project androidannotations-dagger-example: Compilation failure: Compilation failure:
[ERROR] /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/DripCoffeeModule.java:[9,18] 找不到符号
[ERROR] 符号: 类 CoffeeActivity_
[ERROR] @Module(injects = CoffeeActivity_.class, includes = PumpModule.class)
[ERROR] 的文件未关闭;将不针对这些类型进行注释处理
[ERROR] /home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/CoffeeApplication.java:[21,27] 无法将 dagger.ObjectGraph 中的 <T>get(java.lang.Class<T>) 应用于 (coffee.DripCoffeeModule)
[ERROR] -> [Help 1]
@DayS
Copy link
Contributor

DayS commented Jun 16, 2013

As you can see on the Dagger's documentation they split the library in two in this version. So you have to add this dependency :

<dependency>
    <groupId>com.squareup.dagger</groupId>
    <artifactId>dagger-compiler</artifactId>
    <version>${dagger.version}</version>
    <optional>true</optional>
</dependency>

Also, ObjectGraph.get seems to be replaced by ObjectGraph.create.

@pyricau > Maybe you should update your repo :)

@sinojelly
Copy link
Author

@DayS Thanks!
Follow your guide, fixed these errors. but encounter this error:

/home/jelly/code/test/androidannotations-dagger-example/src/main/java/coffee/PumpModule.java:[7,0] Graph validation failed: You have these unused @Provider methods:
    1. coffee.PumpModule.providePump()
    Set library=true in your module to disable this check.
[INFO] 1 error```

@sinojelly
Copy link
Author

I fixed the unused @Provider methods by adding : library=true
And now, it compiles ok, but runs crashed:

06-18 23:23:00.185 E/AndroidRuntime( 6576): FATAL EXCEPTION: main
06-18 23:23:00.185 E/AndroidRuntime( 6576): java.lang.RuntimeException: Unable to create application coffee.CoffeeApplication_: java.lang.TypeNotPresentException: Type coffee/CoffeeActivity_ not present
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4197)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.app.ActivityThread.access$1300(ActivityThread.java:134)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.os.Looper.loop(Looper.java:137)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.app.ActivityThread.main(ActivityThread.java:4788)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at java.lang.reflect.Method.invokeNative(Native Method)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at java.lang.reflect.Method.invoke(Method.java:511)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:541)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dalvik.system.NativeStart.main(Native Method)
06-18 23:23:00.185 E/AndroidRuntime( 6576): Caused by: java.lang.TypeNotPresentException: Type coffee/CoffeeActivity_ not present
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at java.lang.Class.getDeclaredAnnotation(Native Method)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at java.lang.Class.getAnnotation(Class.java:260)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dagger.internal.plugins.reflect.ReflectivePlugin.getModuleAdapter(ReflectivePlugin.java:51)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dagger.internal.RuntimeAggregatingPlugin.getModuleAdapter(RuntimeAggregatingPlugin.java:98)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dagger.internal.RuntimeAggregatingPlugin.getAllModuleAdapters(RuntimeAggregatingPlugin.java:55)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dagger.ObjectGraph$DaggerObjectGraph.makeGraph(ObjectGraph.java:166)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dagger.ObjectGraph$DaggerObjectGraph.access$000(ObjectGraph.java:132)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at dagger.ObjectGraph.create(ObjectGraph.java:129)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at coffee.CoffeeApplication.onCreate(CoffeeApplication.java:21)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at coffee.CoffeeApplication_.onCreate(CoffeeApplication_.java:20)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1001)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4194)
06-18 23:23:00.185 E/AndroidRuntime( 6576):     ... 10 more
06-18 23:23:00.192 I/BroadcastQueue(  309): There are ordered broadcasts stay in queue, should schedule next Broadcasts.
06-18 23:23:00.192 W/ActivityManager(  309):   Force finishing activity info.piwai.androidannotations.dagger.example/coffee.CoffeeActivity_

@sinojelly
Copy link
Author

It runs crashed , if compiled using mvn.
But, if compiled with gradle, runs ok.

See also:
git@github.com:sinojelly/androidannotations-dagger-example.git

commit id: 2ddb33aa9

@DayS
Copy link
Contributor

DayS commented Jul 12, 2013

Sorry for the late answer. Any news about this ?

@sinojelly
Copy link
Author

I fixed the problem, thanks!

@manveer
Copy link

manveer commented Jul 12, 2013

I'm using buck (http://facebook.github.io/buck/) to compile, running into same issue as you described with maven. It builds fine but crashes at runtime. Any idea what may be going on? I'm getting following error at runtime:

E/AndroidRuntime( 2113): java.lang.RuntimeException: Unable to create application com.example.test.app.TestApplication: java.lang.TypeNotPresentException: Type class java.lang.Object$$ModuleAdapter not present
E/AndroidRuntime( 2113): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154)
E/AndroidRuntime( 2113): at android.app.ActivityThread.access$1300(ActivityThread.java:130)
E/AndroidRuntime( 2113): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
E/AndroidRuntime( 2113): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2113): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2113): at android.app.ActivityThread.main(ActivityThread.java:4745)
E/AndroidRuntime( 2113): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2113): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2113): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
E/AndroidRuntime( 2113): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
E/AndroidRuntime( 2113): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2113): Caused by: java.lang.TypeNotPresentException: Type class java.lang.Object$$ModuleAdapter not present
E/AndroidRuntime( 2113): at dagger.internal.FailoverLoader.getModuleAdapter(FailoverLoader.java:39)
E/AndroidRuntime( 2113): at dagger.internal.Modules.getAllModuleAdapters(Modules.java:43)
E/AndroidRuntime( 2113): at dagger.ObjectGraph$DaggerObjectGraph.makeGraph(ObjectGraph.java:167)
E/AndroidRuntime( 2113): at dagger.ObjectGraph$DaggerObjectGraph.access$000(ObjectGraph.java:134)
E/AndroidRuntime( 2113): at dagger.ObjectGraph.create(ObjectGraph.java:126)
E/AndroidRuntime( 2113): at com.example.common.application.ExampleApplication.onCreate(ExampleApplication.java:15)
E/AndroidRuntime( 2113): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
E/AndroidRuntime( 2113): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
E/AndroidRuntime( 2113): ... 10 more
E/AndroidRuntime( 2113): Caused by: java.lang.ClassNotFoundException: java.lang.Object$$ModuleAdapter
E/AndroidRuntime( 2113): at java.lang.VMClassLoader.loadClass(Native Method)
E/AndroidRuntime( 2113): at java.lang.BootClassLoader.findClass(ClassLoader.java:765)
E/AndroidRuntime( 2113): at java.lang.BootClassLoader.loadClass(ClassLoader.java:825)
E/AndroidRuntime( 2113): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 2113): at dagger.internal.loaders.GeneratedAdapters.instantiate(GeneratedAdapters.java:71)
E/AndroidRuntime( 2113): at dagger.internal.loaders.GeneratedAdapters.initModuleAdapter(GeneratedAdapters.java:44)
E/AndroidRuntime( 2113): at dagger.internal.FailoverLoader.getModuleAdapter(FailoverLoader.java:37)
E/AndroidRuntime( 2113): ... 17 more
E/AndroidRuntime( 2113): Caused by: java.lang.NoClassDefFoundError: [generic]
E/AndroidRuntime( 2113): ... 1 more
W/ActivityMan

@yucc136
Copy link

yucc136 commented Aug 31, 2013

how to fix the issue?

@manveer
Copy link

manveer commented Aug 31, 2013

Buck didnt support annotation processing at the time I used it. I moved to using gradle and frankly have found it to be much more suitable for my needs.

@yucc136
Copy link

yucc136 commented Aug 31, 2013

thanks for reply.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants