Describe the solution you'd like
To support appcenter build with the latest gradle plugin, could you please add Java 11?
Current error code:
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
Additional context
https://android-developers.googleblog.com/2020/12/announcing-android-gradle-plugin.html
We can't switch to Android Studio Arctic Fox because of this, which ist required if you want to use Jetpack Compose. Would be nice to get some information about when the update is going to happen.
We were able to work around the problem by adding a pre-build script (appcenter-pre-build.sh, put next to the module level build gradle file) with the following content:
#!/usr/bin/env bash
(echo ""; echo "org.gradle.java.home=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/") >> $APPCENTER_SOURCE_DIRECTORY/gradle.properties
Don't forget to manually trigger "Save & Build" in the build configuration afterwards.
Thanks to Anvesh from Appcenter for pointing us in the right direction.
I couldn't get harry248's solution to work. However it turns out that if you set the JAVA_HOME environment variable to /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/ in the appcenter config for that build it has the same effect.
Most helpful comment
We were able to work around the problem by adding a pre-build script (appcenter-pre-build.sh, put next to the module level build gradle file) with the following content:
Don't forget to manually trigger "Save & Build" in the build configuration afterwards.
Thanks to Anvesh from Appcenter for pointing us in the right direction.