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: 'com.android.application']
> 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`.

* 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 https://help.gradle.org

BUILD FAILED in 1s
Command PhaseScriptExecution failed with a nonzero exit code

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

java

1 Like

Thanks to @ KaterinaPetrova from this thread: https://issueexplorer.com/issue/Kotlin/kmm-production-sample/40#1459679!

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