与 React Native 的兼容性错误 - 整个错误在这里

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

我的系统中的java版本是1.8.0 gradle版本是8.4 科特林是 1.9.0 Groovy 是 3.0.17

现在读取我收到的整个错误,无论我运行 ./gralew clean 还是 ./gradlew assembleDebug 或 npm run android 是 这个——仔细理解后再提出你的建议

Building app...
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'expobareworkflow'.
> Could not determine the dependencies of null.
   > Could not resolve all task dependencies for configuration ':classpath'.
      > Could not find com.android.tools.build:gradle:8.4.
        Searched in the following locations:
          - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.4/gradle-8.4.pom 
          - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.4/gradle-8.4.pom    
        Required by:
            project :
      > Could not resolve com.facebook.react:react-native-gradle-plugin.
        Required by:
            project :
         > No matching variant of project :gradle-plugin 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.4' but:
             - Variant 'apiElements' capability com.facebook.react:react-native-gradle-plugin:unspecified 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.4')      
             - Variant 'mainSourceElements' capability com.facebook.react:react-native-gradle-plugin:unspecified declares a component, and its dependencies declared externally:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)      
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')      
                     - Doesn't say anything about its usage (required runtime)
             - Variant 'runtimeElements' capability com.facebook.react:react-native-gradle-plugin:unspecified 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.4')      
             - Variant 'testResultsElementsForTest' capability com.facebook.react:react-native-gradle-plugin:unspecified:
                 - Incompatible because this component declares a component of category 'verification' and the consumer needed a library
                 - Other compatible attributes:
                     - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                     - Doesn't say anything about its target Java version (required compatibility with Java 8)
                     - Doesn't say anything about its elements (required them packaged as a jar)      
                     - Doesn't say anything about org.gradle.plugin.api-version (required '8.4')      
                     - Doesn't say anything about its usage (required runtime)
BUILD FAILED in 2m 12s
Error: E:\React_native\expo_bare_workflow\android\gradlew.bat exited with non-zero code: 1
java react-native android-studio gradle dependencies
1个回答
0
投票

您使用的 Gradle 插件要求您至少使用 Java 11 运行 Gradle,但您正在使用 Java 8 运行 Gradle。使用较新的 Java 版本来运行 Gradle,它将正常工作,但要保持在 https:// 的范围内/docs.gradle.org/current/userguide/compatibility.html.

© www.soinside.com 2019 - 2024. All rights reserved.