How to downgrade JDK version in github actions?

Viewed 170

I am getting the following error message on github actions when msbuild is run for my xamarin.android project:

_ResolveAndroidTooling:
  Found Java SDK version 14.0.2.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(248,5): error XA0030: Building with JDK version `14.0.2` is not supported. Please install JDK version `11.0`

my actions.yaml looks like this:

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  Android:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          distribution: 'adopt' # See 'Supported distributions' for available options
          java-version: '11'
      #- run: java -cp java HelloWorldApp
      - uses: taori/xamarinandroid-signedbuild-action@v10
        with:
          csproj_path: src/Droid.csproj
          signing_keystore: ${{ secrets.ANDROID_KEYSTORE }}
          keystore_password: ${{ secrets.ANDROID_KEYSTORE_PASS }}
          signing_key_alias: ${{ secrets.ANDROID_KEY_ALIAS }}
          signing_key_password: ${{ secrets.ANDROID_KEY_PASS }}
          configuration: "Release"
          mono_version: "stable"
          xamarin_android_version: "stable"
      - uses: actions/upload-artifact@v2
        with:
          name: ipa
          path: src/*.Droid/bin/Android/Release/**Signed.apk

Does actions/setup-java@v2 not install 11.x? Or is this an issue with msbuild not picking up on the environment variables set by that action?

References

Known issue for azure pipelines

1 Answers

Does actions/setup-java@v2 not install 11.x?

It should, since PR 132 and v2.

Try and simplify your action, to only keep the java installation part, and validate it does work:

- name: setup-java
  uses: actions/setup-java@v2-preview
  with:
    distribution: 'adopt'
    java-version: '11'

Then add back the other elements of your original action, and see when the issue manifests itself again.

Related