android-analyzer
android-analyzer copied to clipboard
Task :app:compileDebugJavaWithJavac FAILED
Hello,
I just added this plugin, and executed: But got the following error:
Task :app:kaptDebugKotlin FAILED e: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
So I googled it, and got the answer to add JAX-B dependencies, So I added the following dependencies:
implementation "javax.xml.bind:jaxb-api:2.2.12-b140109.1041"
implementation "com.sun.xml.bind:jaxb-core:2.2.11"
implementation "com.sun.xml.bind:jaxb-impl:2.2.11"
implementation "javax.activation:activation:1.1.1"
When I added these and execute then get the following error:
Execution failed for task ':app:compileDebugJavaWithJavac'.
javax/xml/bind/JAXBException
This is my project level build.gradle:
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://raw.github.com/pinchbv/android-analyzer/master/repo" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.0.0"
classpath "com.justpinch:androidanalyzer:1.2.2"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://kotlin.bintray.com/kotlinx/" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Same kind of errors I'm' getting when I used the following tutorial with default SonarQube Config: https://medium.com/@sandeeptengale/integrate-sonarqube-for-android-application-development-8e40ec28e343
Please, can you help to resolve this issue, Thanks
Thanks for submitting an issue. Since you are getting the same kind of bugs when using Sonarqube directly, looks like it is not related to the plugin.
I have a feeling you might be trying to use a higher Java version than Android supports for the build. Could you verify that your JAVA_HOME points to Java 7 or 8 and not something higher?
same ,i get the error
Task :app:kaptDebugKotlin FAILED e: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException ,,,,,
,,, FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:kaptDebugKotlin'.
Internal compiler error. See log for more details
Thanks for your comment. Could you please tell me your Java version?
Type the following in the terminal: java -version.
Thanks and looking forward to helping you.
i use /opt/android-studio/jre , and the version is
> java -version
openjdk version "11.0.5-ea" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5-ea+6-post-Debian-2)
OpenJDK 64-Bit Server VM (build 11.0.5-ea+6-post-Debian-2, mixed mode, sharing)
already test with this dependency
// JAX-B dependencies for JDK 9+
implementation "javax.xml.bind:jaxb-api:2.2.12-b140109.1041"
....
right now i got warning after update gradle version
The following project options are deprecated and have been removed:
analyze stacktrace result the android.databinding.enableV2=true is deprecated ?
still get the error when i try to
./gradlew clean
./gradlew assembleDebug or installDebug
Android Studio 3.5.1
Build #AI-191.8026.42.35.5900203, built on September 26, 2019
JRE: 1.8.0_202-release-1483-b49-5587405 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.2.0-kali2-amd64
if you want to look more the detail , i could you test , this my project tutorial https://github.com/yogithesymbian/MVVM-Kotlin-Android-Studio sorry before :D
that's bug on jdk > 8 9 10 11 ?
I am also getting this issue.
$ java --version
java 12.0.1 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
> Task :data:kaptDebugKotlin FAILED
e: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3143)
...
I can get it to work if I add the explicit Java 8 path:
./gradlew androidAnalyzer -Dorg.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home
This is caused by the module system that was introduced with Java 9. The JAXB APIs are considered to be Java EE APIs, and are therefore are no longer contained on the default classpath in Java 9. Depending on your Java version, you have a few options:
If you're on Java 9 or 10, you can add using the relevant module using the command line option --add-modules java.xml.bind. This would be a temporary workaround...
... since the the Java EE modules were removed with Java 11. Hence, the best approach moving forward is to add the dependency to your classpath using a dependency management tool, such as Maven or Gradle:
Maven:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>xxx</version>
</dependency>
Gradle:
implementation "javax.xml.bind:jaxb-api:xxx"
@AndroideRob It may make sense for the plugin to declare this dependency for Java 9(+) consumers, but not sure if there would be any detrimental effects for those on lower versions (e.g. conflicts on dupe classes).
@mhelder thank you for an explanation and a workaround.
I will check if it is possible to declare the dependency on jaxb within the plugin and keep you guys posted @mhelder @KatieBarnett-Bilue @yogithesymbian @Parag2385
thank you @mhelder @AndroideRob @KatieBarnett-Bilue already solved :D in android studio. spending 3 days ,
when i try --add-modules java.xml.bind
i got java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception
so i try added implementation "javax.xml.bind:jaxb-api:2.3.1"
i got same error
i got duplicate classes of javax , what the .... (
dunno why , ok i added
defaultConfig {
multiDexEnabled True
}
clean and rebuild still get the error cant assembleDebug and installDebug build failed i try add this
implementation "javax.xml.bind:jaxb-api:2.3.1"
// these
implementation "com.sun.xml.bind:jaxb-core:2.2.11"
implementation "com.sun.xml.bind:jaxb-impl:2.2.11"
implementation "javax.activation:activation:1.1.1"
trace the duplicate and remove the implementation "javax.activation:activation:1.1.1"
so in here case i got duplicate classess alr and still get error, when i try add the dependency i have duplicate ? , @_@
if i try assembleDebug --info with normal user i have denied todo in /home/user/.gradle/..... , then i change permission folder to my user , same , then if try root / sudo ./gradlew asseembleDebug , i got same error e: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
so try running android studio as root , clean and rebuild , running , viola works...~~ if i run android studio 3.5.1 as normal user i can click run app in GUI but install app dissappear , not install apps only build /gradle can, so i always manual with installDebug and assembleDebug on CLI
conclusion in this case i need multipleBuild , the 3 dependency , and run as root.
sorry my english , correct me if wrong :D .
I resolved temporary this issu as follow:
create a libs folder in app directory
copy the following jars in libs:
FastInfoset-1.2.15.jar
jaxb-api-2.4.0-b180830.0359.jar
istack-commons-runtime-3.0.7.jar
jaxb-runtime-2.4.0-b180830.0438.jar
javax.activation-api-1.2.0.jar
stax-ex-1.8.jar
run commands
./gradlew -Drg.gradle.jvmargs='-cp ./libs/' assembleDebug
./gradlew -Drg.gradle.jvmargs='-cp ./libs/' installDebug
My application that use data binding and viewModel binding works fine :)
I am waiting for an elegent solution.
@ezzahir I'm still getting the same error while my detekt scan is successful but report didn't sync with sonarqube
detekt finished in 1179 ms. Successfully generated HTML report at E:.........\app\build\reports\detekt\detekt.html Successfully generated Checkstyle XML report at E:..........\app\build\reports\detekt\detekt.xml Successfully generated plain text report at E:.........\app\build\reports\detekt\detekt.txt Build succeeded with 137 weighted issues (threshold defined was 100000).
Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
javax/xml/bind/JAXBException