DEV Community

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

Posted on • Updated on

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 ( after checking the Bug Database ( for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class$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:

  • 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):

    name: Deploying to Playstore
    runs-on: macos-11
      - 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
          distribution: 'liberica'
          java-version: '11'
          cache: 'gradle'
Enter fullscreen mode Exit fullscreen mode

See for more configuration regarding distribution, version and caching.

Top comments (0)