NoClassDefFoundError on ObjectGraph
Hi
I'm getting the following java.lang.NoClassDefFoundError: dagger.ObjectGraph when my app launches
I'm just trying to get dagger implemented into my app. Ive disabled proguard as I thought this was at fault. I'm using gradle as the build system, but can't seem to get around this issue, any help would be great.
Thanks
Show your dependencies closure from your build file. On Nov 27, 2013 1:58 PM, "Wade Reweti" [email protected] wrote:
Hi
I'm getting the following java.lang.NoClassDefFoundError: dagger.ObjectGraph when my app launches
I'm just trying to get dagger implemented into my app. Ive disabled proguard as I thought this was at fault. I'm using gradle as the build system, but can't seem to get around this issue, any help would be great.
Thanks
— Reply to this email directly or view it on GitHubhttps://github.com/square/dagger/issues/362 .
attached below
dependencies {
compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.squareup.dagger:dagger-compiler:1.0.1'
compile 'com.squareup.dagger:dagger:1.0.1'
compile files('/Users/wadereweti/Projects/dependencies/activeandroid-3.1-beta.jar')
}
Thanks
You need the actual dagger dependency to be available at runtime.
thanks cgruber, but I would've thought, given it's available at compile time, it would be available at runtime.
having to write both
compile 'com.squareup.dagger:dagger-compiler:1.0.1' compile 'com.squareup.dagger:dagger:1.0.1'
runtime 'com.squareup.dagger:dagger-compiler:1.0.1' runtime 'com.squareup.dagger:dagger:1.0.1'
doesn't seem right to me
Sorry - I"m not a gradle guy - I literally know nothing about how gradle specifies, or how its dependency scopes work. A brief examination of relevant web-pages tells me that dep configurations don't work like maven scopes, though you can simulate them. But I have no idea how without further investigation. I would check on the gradle lists, or post a stack-overflow question.
As to my earlier comment - I'm only making a statement about an environmental constraint, not about how you configure that in gradle. And I'm observing that the bytes aren't there in your run-time classpath, or you would not get a NoClassDefFound. :)
yep right you are, thanks man.
You can see some Gradle solutions in #325. Placing both artifacts in the compile scope should absolutely work. Are you sure something else like ProGuard isn't affecting the classes? Also, are you doing a clean build from the command line or just in the IDE. The IDE isn't going to pick up the dependencies unless you refresh its model (in the Gradle pane) and even sometimes then it may not include them. You'll want to go to "Build" > "Rebuild Project" to do a clean build after click the aforementioned "Refresh" button.
I started getting this with Android Studio 0.9.0 and build tools 21.1.0. I had compile for dagger and dagger-compiler before, which was working well.
After the update, setting dagger-compiler to apt fixed the problem.