Gradle task embedAndSignAppleFrameworkForXcode for Xcode run failed all the time

I created a KMM project using Android Studio Arctic Fox KMM wizard. Then I used Xcode 12.4 to open the iosApp generated by the wizard. Then I run iosApp on iPhone 12 target, but the script ./gradlew :shared:embedAndSignAppleFrameworkForXcode always failed because of java version:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user/AndroidStudioProjects/OrderBook/androidApp/build.gradle.kts' line: 1

* What went wrong:
An exception occurred applying plugin request [id: '']
> Failed to apply plugin ''.
   > 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 `` in ``.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

Command PhaseScriptExecution failed with a nonzero exit code

However, I’ve already using Java 11 instead of Java 8. My environment are like followings:


1 Like

Thanks to @ KaterinaPetrova from this thread:!

I solved it by adding " export JAVA_HOME=’/Applications/Android’" in the beginning of the Run Script .