Search code examples
androidgradlegradlew

Android Studio compiles project correctly, Gradlew does not with Databinding enabled


After extensive google-ing and searching SO, I was not able to sufficiently find a solution to my problem.

The issue:

My project currently has Databinding v2 enabled and in my XML I do have 2 way data binding for view model properties.

Android Studio (v3.5.3) is able to compile the project fine and doesn't have any errors

Using the command line tool ./gradlew assemble<Release_type> would result in

javax/xml/bind/JAXBException

The solution:

There were some hints on Google and SO regarding a change made from Java8 -> Java11 regarding this library. I'm not entirely sure what that change was but Java11 doesn't include whatever library that is needed to compile the app. Upon further inspection, I realized I was running OpenJDK 11 and not OpenJDK 8. According to various sources, the solution to this problem was to install OpenJDK 8.

Steps to success:

  1. Uninstall OpenJDK 11 or greater
  2. Run the following command
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk8
  1. Now running ./gradlew assemble<release_type> should work as expected.

What this solves

  1. fastlane not being able to build
  2. gradlew not able to build

Conclusion

Further google searching led me to a couple of articles related to OpenJDK 11. Apparently, Android Studio doesn't support OpenJDK 11 yet but Android Studio 4.x will. - reference to SO post

I know this isn't an "actual" question but I leave this here in hopes that anyone else super frustrated (like myself) finds this potential solution useful and hopefully Google indexes this article :)


Solution

  • Please see above for detailed Solution

    TLDR

    Steps to success:

    Uninstall OpenJDK 11 or greater Run the following command brew tap AdoptOpenJDK/openjdk brew cask install adoptopenjdk8 Now running ./gradlew assemble should work as expected.