如何解决“但是我们无法在 org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10 的以下变体之间进行选择”的问题

pet*_*iop 6 android react-native

我有一个旧的反应原生项目,我正在尝试运行。当我安装了节点模块并现在在模拟器上运行应用程序时,我收到以下错误

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all dependencies for configuration ':app:debugCompileClasspath'.      
   > A problem occurred configuring project ':react-native-async-storage_async-storage'.  
      > Could not resolve all artifacts for configuration ':react-native-async-storage_async-storage:classpath'.
         > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10.
           Required by:
               project :react-native-async-storage_async-storage
            > The consumer was configured to find a runtime of a component compatible with Java 11, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10: 
                - gradle70JavadocElements
                - gradle70RuntimeElements
                - gradle70SourcesElements
                - gradle71JavadocElements
                - gradle71RuntimeElements
                - gradle71SourcesElements
                - gradle75JavadocElements
                - gradle75RuntimeElements
                - gradle75SourcesElements
                - gradle76JavadocElements
                - gradle76RuntimeElements
                - gradle76SourcesElements
                - javadocElements
                - runtimeElementsWithFixedAttribute
                - sourcesElements
Run Code Online (Sandbox Code Playgroud)

我尝试更改 java 版本,将“org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10”放入项目中,但最初并不存在。

所以我的机器中已经有 kotlin,但我不确定问题出在哪里,因为库“:react-native-async-storage_async-storage”是导致问题的原因。

而且我检查了项目,项目中之前没有使用kotlin,为什么现在要kotlin

小智 0

对我来说,这个临时解决方法可以完成这项工作:

降级反应本机异步存储

yarn upgrade @react-native-async-storage/async-storage@^1.10.0
Run Code Online (Sandbox Code Playgroud)

并通过替换以下内容来降级react-native-async-storage/build.gradle中的Kotlin版本:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$asyncStorageKtVersion"
Run Code Online (Sandbox Code Playgroud)

和:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
Run Code Online (Sandbox Code Playgroud)

请注意,每次更改 node_modules 中的某些内容时,您都可以重复最后一步