Christopher Mathews
Christopher Mathews

Reputation: 191

Multiplatform error when building iosApp: Command PhaseScriptExecution failed with a nonzero exit code

I am working on a multiplatform app in Kotlin on Android Studio and when I try to run the app to an iOS simulator, I get this error:

The following build commands failed:

PhaseScriptExecution [CP-User]\ Build\ shared /Users/cjm/AndroidStudioProjects/GlobeMultiplatform/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-882AF45D8B8C4938AC461F4FBA0FE197.sh (in target 'shared' from project 'Pods')

The code in the build.gradle that sets the cocoa pods is this:

cocoapods {
    summary = "Shared"
    homepage = "Link to the Shared Module homepage"
    ios.deploymentTarget = "13"
    frameworkName = "shared"
    podfile = project.file("../iosApp/Podfile")
}

I ran pod install and it showed success but the build of the app still fails. How can I fix this error? What is causing this error? I am brand new to Kotlin and especially Kotlin Multiplatform so I apologize if this is a stupid question.

EDIT: Here's what Xcode says when running the app:

FAILURE: Build failed with an exception.

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.

Upvotes: 13

Views: 6953

Answers (2)

Janaco
Janaco

Reputation: 1683

I also faced this error to run my KMP project to ios emulator. Just install the current version of Java: Java Download

After installing the problem was gone.

Upvotes: 0

Róbert Nagy
Róbert Nagy

Reputation: 7680

It seems that it tries to build your code with Java 1.8, you need a Java > 11 version.

I'd look into this or other guidelines to make sure the proper JDK version is used

Upvotes: 11

Related Questions