groovy / groovy-android-gradle-plugin

A Gradle plugin to support the Groovy language for building Android apps
Apache License 2.0
850 stars 116 forks source link

Build failed on Android Studio 2.2 when using data binding #134

Closed sakuna63 closed 7 years ago

sakuna63 commented 8 years ago

Below error printed when building android project on Android Studio 2.2 with using data binding.

Error:Execution failed for task ':app:compileDebugAndroidTestGroovyWithGroovyc'.
> java.lang.RuntimeException: failure, see logs for details.
  Could not write to com.sakuna63.sandbox.test.BR javax.annotation.processing.FilerException: Attempt to recreate a file for type com.sakuna63.sandbox.test.BR
  at com.sun.tools.javac.processing.JavacFiler.checkNameAndExistence(JavacFiler.java:522)
  at com.sun.tools.javac.processing.JavacFiler.createSourceOrClassFile(JavacFiler.java:396)
  at com.sun.tools.javac.processing.JavacFiler.createSourceFile(JavacFiler.java:378)
  at android.databinding.tool.writer.AnnotationJavaFileWriter.writeToFile(AnnotationJavaFileWriter.java:41)
  at android.databinding.annotationprocessor.ProcessBindable.generateBRClasses(ProcessBindable.java:123)
  at android.databinding.annotationprocessor.ProcessBindable.onHandleStep(ProcessBindable.java:84)
  at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.runStep(ProcessDataBinding.java:154)
  at android.databinding.annotationprocessor.ProcessDataBinding$ProcessingStep.access$000(ProcessDataBinding.java:139)
  at android.databinding.annotationprocessor.ProcessDataBinding.process(ProcessDataBinding.java:66)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
  at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
  at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
  at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
  at com.sun.tools.javac.main.Main.compile(Main.java:523)
  at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
  at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
  at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:46)
  at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:33)
  at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler$2$1.compile(ApiGroovyCompiler.java:163)
  at org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit.gotoPhase(JavaAwareCompilationUnit.java:105)
  at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:556)
  at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:525)
  at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:173)
  at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:59)
  at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:31)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:87)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
  at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
  at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
  at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
  at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

But I don't encounter this error when I build on command line, like ./gradlew assembleDebug.

You can reproduce error : https://github.com/sakuna63/Sandbox-Android/tree/groovy

AndrewReitz commented 8 years ago

Try removing skipJavaC since you need javaC to run in order to have annotation processors run.

sakuna63 commented 8 years ago

Thanks for your reply!!

I've already tried it. but I encountered same error, without skipJavaC.

ref: https://github.com/sakuna63/Sandbox-Android/commit/6ea58c786598e51de01ab085d9b5fd03266265fa

AndrewReitz commented 8 years ago

What does the reference have to do with anything?

Please change

androidGroovy {
    skipJavaC = true
    options {
        configure(groovyOptions) {
            javaAnnotationProcessing = true
        }
    }
}

to

androidGroovy {
    options {
        configure(groovyOptions) {
            javaAnnotationProcessing = true
        }
    }
}

If this additionally causes issues please include those here.

Adding a failing databinding test similar to the ones found here https://github.com/groovy/groovy-android-gradle-plugin/tree/05457107cf6e7c310a1c1a24f82b83c9fbbd0d2c/groovy-android-gradle-plugin/src/test/groovy/groovyx/functional I'd be able to more quickly support you.

Also, you are not using groovy in your application so I am unsure why you are including this plugin.

AndrewReitz commented 7 years ago

@sakuna63 can you provide an update?