13

Error

org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures. Caused by: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugJavaWithJavac'. Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I'm getting this this error when I enable dataBinding and try to build on IntelliJ IDEA, building with gradlew build works, and on Android Studio works too.

Versions

Gradle version: 5.1.1

IDEA: 2019.1.3

Android plugin: (latest as of 18 jun)

Java: 8


To reproduce, create a project on Android Studio, enable dataBinding, and open it on IDEA and try to build.

Does anyone know why these conflicts are happening?

John Sardinha
  • 3,566
  • 6
  • 25
  • 55
  • 2
    What JDK do you use to run IDE under? If 11, try switching to the 1.8 JDK: https://www.jetbrains.com/help/idea/switching-boot-jdk.html#d746506e20 Also set 1.8 As **Gradle JVM** in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle settings. – Andrey Jun 18 '19 at 10:35
  • Try also `--add-modules java.xml.bind` into Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | **Gradle VM options**. – Andrey Jun 18 '19 at 10:41

4 Answers4

4

Try this:

Right-click on a project module -> Open Module Settings -> Platform Settings | SDKs -> Click on each Android Api in the SDKs list. And make sure Java SDK 1.8 is selected

luca992
  • 1,548
  • 22
  • 27
4

Android Studio 3.6.3 On Windows,

Go to File -> Project Structure (Shortcut: Ctrl+Alt+Shift+S)

Navigate to SDK Location

From the JDK location dropdown, choose Embedded JDK

enter image description here

P.S. Read this answer to know the possible reasons. So it is the safest option to use the embedded JDK.

Roaim
  • 2,298
  • 2
  • 11
  • 23
1

For Artic Fox Android studio version :

File > ProjectStructure > There is option "JDK location was moved to Gradle Settings."

enter image description here

Click on Gradle Setings

there is dropdown option as Gradle JDK, Select your appropriate jdk version from dropdown enter image description here

After this Sync your project and create build.

Ritesh
  • 533
  • 2
  • 7
  • 18
0

From @Andrey's comment:

--add-modules "java.xml.bind" into Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle VM options.

Edit: This worked at first, but the same error happened after creating a databinding layout.

John Sardinha
  • 3,566
  • 6
  • 25
  • 55