Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoSuchMethod Exception #113

Closed
chrisjenx opened this issue Feb 3, 2015 · 25 comments
Closed

NoSuchMethod Exception #113

chrisjenx opened this issue Feb 3, 2015 · 25 comments
Assignees

Comments

@chrisjenx
Copy link

I think this is related to the latest google/auto snapshot pushed today. But dagger-compiler throws the following error:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJava'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)
    at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:46)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: com.google.auto.common.MoreTypes.asTypeElements(Ljavax/lang/model/util/Types;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableSet;
    at com.sun.tools.javac.main.Main.compile(Main.java:469)
    at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:42)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:35)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:97)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:50)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:36)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:34)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.execute(CleaningJavaCompilerSupport.java:25)
    at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:158)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:138)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:92)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:235)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:222)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 54 more
Caused by: java.lang.NoSuchMethodError: com.google.auto.common.MoreTypes.asTypeElements(Ljavax/lang/model/util/Types;Ljava/lang/Iterable;)Lcom/google/common/collect/ImmutableSet;
    at dagger.internal.codegen.ComponentDescriptor$Factory.create(ComponentDescriptor.java:124)
    at dagger.internal.codegen.ComponentDescriptor$Factory.forComponent(ComponentDescriptor.java:114)
    at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:74)
    at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:222)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:722)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1700(JavacProcessingEnvironment.java:97)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1029)
    at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1163)
    at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1108)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
    at com.sun.tools.javac.main.Main.compile(Main.java:439)
    ... 72 more
@hiBrianLee
Copy link

I am also seeing this when using snapshot:
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'

Maybe related to google/auto@e02e2a8?

@hiBrianLee
Copy link

Yeah seems like asTypeElements method changed - google/auto@e02e2a8#diff-117761445d686cc88f0b75d965af5a1aL466

@hiBrianLee
Copy link

What's the correct way to set up gradle to use the jar files to avoid SNAPSHOT issues like this?

I've tried

apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    compile files('libs/dagger-2.0-20150122.022617-13.jar');
    apt files('libs/dagger-compiler-2.0-20150122.022637-13.jar');
    compile 'javax.inject:javax.inject:1'
    provided 'javax.annotation:javax.annotation-api:1.2'
}

but it doesn't seem to be working. It compiles without error but it force closes when I run the app (Caused by: java.lang.ClassNotFoundException: Didn't find class "com.abc.CustomApplication" on path: DexPathList), and intelliJ also doesn't seem be able to find Dagger_AppComponent.builder() that's reference in the CustomApplication file. I didn't see these issues when using SNAPSHOT from maven directly, and would like to know how to use the JAR files directly.

@JakeWharton
Copy link

You haven't included the dependencies of the dagger-compiler on the apt classpath.

@hiBrianLee
Copy link

Thanks. Adding the following based on the pom.xml file worked (to use the dagger-compiler jar, sort of)

    apt files('libs/dagger-producers-2.0-20150122.022620-1.jar');
    apt 'com.google.auto:auto-common:1.0-SNAPSHOT'
    apt 'com.squareup:javawriter:2.5.0'
    apt 'com.google.guava:guava:18.0'

However, since dagger-compiler depends on the snapshot version of auto-common anyway, back to square one I guess!

For others running into this NoSuchMethodError issue, you can (temporarily) include the previous auto-common snapshot from https://oss.sonatype.org/content/repositories/snapshots/com/google/auto/auto-common/1.0-SNAPSHOT/ as a work around.

    compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
    apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
    provided 'javax.annotation:javax.annotation-api:1.2'
    apt files('libs/auto-common-1.0-20150122.001631-7.jar');
    apt 'com.google.guava:guava:18.0'

@artem-zinnatullin
Copy link

Damn, this is bad, one snapshot library depends on another snapshot library.. Callback snapshot hell.

What about semantic versioning and/or fixed inner dependencies? I don't want to talk about #109, but inner snapshot dependencies — serious problem for production

@JakeWharton
Copy link

Ugh, please no. A shaded compiler jar is all that's needed.

@artem-zinnatullin
Copy link

Downloading jars... Interesting, how many developers are currently thinking "WTF with my build?" :)

@rapropos
Copy link

rapropos commented Feb 4, 2015

To expand a bit on the workaround, you need to download and reference three separate jars, temporarily replacing the dagger-compiler dependency with the following:

apt files('libs/dagger-producers-2.0-20150122.022620-1.jar')
apt files('libs/dagger-compiler-2.0-20150122.022637-13.jar')
apt files('libs/auto-common-1.0-20150122.001631-7.jar')
apt 'com.squareup:javawriter:2.5.0'
apt 'com.google.guava:guava:18.0'

@chrisjenx chrisjenx changed the title NoSuchMethod, Exception NoSuchMethod Exception Feb 4, 2015
@vishna
Copy link

vishna commented Feb 4, 2015

With the above workaround I was running into java.lang.ClassNotFoundException in android runtime so I did the following:

apt ('com.google.dagger:dagger-compiler:2.0-SNAPSHOT') {
        exclude group: 'com.google.auto'
}
apt files('libs/auto-common-1.0-20150122.001631-7.jar')

so that requites only one jar instead of three, hopefully this gets fixed soon

@mgrzechocinski
Copy link

IMHO it might be done easier, since fortunately dagger-compiler has it's jar-with-dependencies variant (download it).

Here's how I changed my build.gradle:

-   compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
+   compile files('libs/dagger-2.0-20150122.022617-13.jar');
+   compile 'javax.inject:javax.inject:1' //transient dependency of Dagger core

-   apt "com.google.dagger:dagger-compiler:2.0-SNAPSHOT"
+   apt files('libs/dagger-compiler-2.0-20150122.022637-13-jar-with-dependencies.jar');

Actually, this is madness (#109). But it works.

@confile
Copy link

confile commented Feb 4, 2015

+1 I have the same problem.

@koalahamlet
Copy link

I was seeing this error earlier as well. Just out of interest, was that causing peoples Dagger_{whatever}Component to not be compiled correctly?

@cgruber
Copy link

cgruber commented Feb 4, 2015

I am in the process of exporting a new update - this was the syncs getting out of sync, and I"ll fix. I'm also going to be jarjar-ing the binary so when we publish a snapshot (or release) it'll be resistent to dependency version skew.

@cgruber cgruber self-assigned this Feb 4, 2015
@cbeust
Copy link

cbeust commented Feb 4, 2015

👍

@chrisjenx
Copy link
Author

Thanks @cgruber!

@sbuettner
Copy link

Thank you for looking into this.

@cgruber
Copy link

cgruber commented Feb 5, 2015

PR #115 fixes this. Should merge shortly.

@cgruber
Copy link

cgruber commented Feb 5, 2015

So - apologies for all of this. Having seen these interactions, I'm going to do a little work on my end to keep us from dealing with this sort of skew. But the new version should be out, and it should work.

@artem-zinnatullin
Copy link

@cgruber it's okay for alpha-beta-whatever-snapshot, at least, Dagger didn't delete /usr/ folder 👍

@kboyarshinov
Copy link

Thanks! 👍

@ksidpen
Copy link

ksidpen commented Feb 5, 2015

Appreciated

@damianpetla
Copy link

It's alive again! Thanks @cgruber !

@pakoito
Copy link

pakoito commented Feb 5, 2015

👍 💯

@chrisjenx
Copy link
Author

I'll close this now. As this is working with the latest snapshot. Thanks @cgruber (and co).

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

No branches or pull requests