DEV Community

Cover image for Upgrade to Gradle JDK 11 on Github Actions
Kyle Foo
Kyle Foo

Posted on • Edited on

3 3

Upgrade to Gradle JDK 11 on Github Actions

Getting a compiler exception while building Android on Github Actions?

> Task :react-native-device-info:compileReleaseJavaWithJavac FAILED
An exception has occurred in the compiler (1.8.0_322). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
Enter fullscreen mode Exit fullscreen mode

In my case, react-native-device-info requires newer Gradle JDK during build. Hence, we need to update the JDK reference to version 11, not the default JDK 8 that uses version 1.8 compiler. See: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md#java

  • I'm using macos-11 Image on Github Actions.

In our local machine, we can do the upgrade here in Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle > Select Gradle JDK version:
Image description

On CI/CD, we can configure the environment to upgrade to JDK 11. For example, in Github Actions deployment steps, we add a upgrade step (Set up JDK 11):

jobs:
  deploy:
    name: Deploying to Playstore
    runs-on: macos-11
    steps:
      - name: Checkout Code
        uses: actions/checkout@v2
      - name: Install Dependencies
        run: yarn
        working-directory: ${{ env.working-directory }}
      - name: Set up JDK 11
        uses: actions/setup-java@v2
        with:
          distribution: 'liberica'
          java-version: '11'
          cache: 'gradle'
Enter fullscreen mode Exit fullscreen mode

See https://github.com/actions/setup-java for more configuration regarding distribution, version and caching.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay