Closed barriosnahuel closed 8 years ago
Ok, just tried your project and reproduced the error.
Running with -debug
I see this:
00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing archive /home/jmsotuyo/.gradle/caches/modules-2/files-2.1/com.android.databinding/compiler/2.2.0-alpha5/173b5ba5ec9d2a71350da24c7c239ed5a54179bb/compiler-2.2.0-alpha5.jar... 00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/... 00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/MANIFEST.MF... 00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/compiler-compileKotlin.kotlin_module... 00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/kotlin-runtime.kotlin_module... 00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/kotlin-stdlib.kotlin_module... 00:42:23.798 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/services/... 00:42:23.808 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing META-INF/services/javax.annotation.processing.Processor... 00:42:23.811 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing NOTICE... 00:42:23.811 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing NOTICE.txt... 00:42:23.811 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing android/... 00:42:23.811 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing android/databinding/... 00:42:23.811 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing android/databinding/annotationprocessor/... 00:42:23.811 [DEBUG] [com.android.build.gradle.internal.ApplicationTaskManager] processing android/databinding/annotationprocessor/AnnotationUtil.class... 00:42:23.812 [ERROR] [org.gradle.api.Project] Dex: Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugin in a library submodule add targetCompatibility = '1.7' sourceCompatibility = '1.7' to that submodule's build.gradle file.
I opened the compiler-2.2.0-alpha5.jar
, extracted android/databinding/annotationprocessor/AnnotationUtil.class
and by using javap -v
on it found that, unsurprisingly, it's compiled for JRE 8.
This jar is used for annotation processing, so it's not to be included on the dex. This is clearly a bug on Android's plugin 2.2.0-alpha5, and is not present in version 2.1.2.
For the time being, I recomend you switch back to Android plugin 2.1.2, and report the issue on http://b.android.com/
Remember, android-24
requires Java 8:
- What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
compileSdkVersion 'android-24' requires JDK 1.8 or later to compile.
I still can't reproduce your first error (Unsupported major.minor version 52.0
on Java 7). I'm leaving this issue open until we can reproduce it or finally dismiss it. Could you provide a sample on which Java 7 produces such output?
I got to reproduce your error, it's the Android Gradle plugin itself that is built for JRE 8. Even without SCA I get that error on java 7.
So, both issues here are with Android or your setup.
Bottomline:
Solution:
Android Gradle plugin 2.2.0-alpha6 has just been released, and it seems to fix this dexing issue. You could use it safely.
I'm using the plugin ok but when I tried to start using Data Binding, the project synced well but gives me an error running task:
:installDebug
.It seems that the plugin either has any conflicting dependency with DataBinding or it is compiled for Java8 only (but I see it's compiling for compatibility with 7
What I tested
java -version Java7
Note that DataBinding works ok in Java7.
java -version Java8
Without DataBinding
works ok! =)
With DataBinding
Sandbox
You can un/comment this line where I'm applying this plugin to reproduce the error. That branch is using DataBinding and works ok without applying static-code-analysis =(