面临从 Kotlin 多平台移动应用程序运行 iOS 应用程序的问题

问题描述 投票:0回答:1

我正在尝试运行从 Kotlin 多平台模板创建的示例应用程序,我没有更改任何内容。它适用于 Android,但不适用于 iOS。我尝试通过从 Xcode 创建仅适用于 iOS 的示例应用程序来进行检查,该应用程序工作正常。我使用的是 Xcode 15.4,我的 mac 操作系统是 Sonoma 版本 14.6.1

* What went wrong:
A problem occurred configuring root project 'TestKMP'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:8.5.2.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:8.5.2
         project : > com.android.library:com.android.library.gradle.plugin:8.5.2
      > No matching variant of com.android.tools.build:gradle:8.5.2 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.7' but:
          - Variant 'apiElements' declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'javadocElements' declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')
          - Variant 'sourcesElements' declares a component for use during runtime, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Doesn't say anything about its target Java version (required compatibility with Java 8)
                  - Doesn't say anything about org.gradle.plugin.api-version (required '8.7')

* Try:
> Review the variant matching algorithm at https://docs.gradle.org/8.7/userguide/variant_attributes.html#sec:abm_algorithm.
> No matching variant errors are explained in more detail at https://docs.gradle.org/8.7/userguide/variant_model.html#sub:variant-no-match.
> 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 2s
Configuration cache entry stored.
Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution Run\ Script /Volumes/Macintosh_HD_Data/KMP/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')
(1 failure)
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'iosApp' from project 'iosApp')

以下是 kdoctor 结果: enter image description here

ios iphone kotlin-multiplatform
1个回答
0
投票

检查

build.gradle.kts
shared
下的
composeApp
文件。

有可能,您已将以下仅限 Android 的依赖项添加到您的

iosMain
依赖项中:

iosMain.dependencies {
    implementation("com.android.tools.build:gradle:8.5.2") // just remove this
}
© www.soinside.com 2019 - 2024. All rights reserved.