AppCenter:无法解析com.facebook.react:react-native-gradle-plugin

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

我使用最新的 React Native 版本 0.73.5 创建了新应用程序。当我在本地运行/构建时一切都很顺利。然后当我开始在我的应用程序中心构建它时,我会收到此错误

`* What went wrong:
 A problem occurred configuring root project 'SPIMarch2024'.
 > Could not determine the dependencies of null.
 > Could not resolve all task dependencies for configuration ':classpath'.
 > 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.3' 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.3')
         - 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.3')
                 - 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.3')
         - 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.3')
                 - Doesn't say anything about its usage (required runtime)`

项目级别build.gradle

buildscript {
ext {
    buildToolsVersion = "34.0.0"
    minSdkVersion = 21
    compileSdkVersion = 34
    targetSdkVersion = 34
    ndkVersion = "25.1.8937393"
    kotlinVersion = "1.8.0"
}
repositories {
    google()
    mavenCentral()
}
 dependencies {
    classpath("com.android.tools.build:gradle:7.3.1")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
 }
}

apply plugin: "com.facebook.react.rootproject"

设置.gradle

   rootProject.name = 'SPIMarch2024'
   apply from: file("../node_modules/@react-native-community/cli-platform-                     
   android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
   include ':app'
   includeBuild('../node_modules/@react-native/gradle-plugin')

gradle-wrapper.properties

   distributionBase=GRADLE_USER_HOME
   distributionPath=wrapper/dists
   distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
   networkTimeout=10000
   validateDistributionUrl=true
   zipStoreBase=GRADLE_USER_HOME
   zipStorePath=wrapper/dists

应用程序级别build.gradle

    apply plugin: "com.android.application"
    apply plugin: "org.jetbrains.kotlin.android"
    apply plugin: "com.facebook.react"


    react {

    }


    def enableProguardInReleaseBuilds = false


    def jscFlavor = 'org.webkit:android-jsc:+'

    android {
        ndkVersion rootProject.ext.ndkVersion
        buildToolsVersion rootProject.ext.buildToolsVersion
        compileSdkVersion rootProject.ext.compileSdkVersion

        namespace "com.spimarch2024"
        defaultConfig {
            applicationId "com.spimarch2024"
            minSdkVersion rootProject.ext.minSdkVersion
            targetSdkVersion rootProject.ext.targetSdkVersion
            versionCode 1
            versionName "1.0"
        }
        signingConfigs {
            debug {
                storeFile file('debug.keystore')
                storePassword 'android'
                keyAlias 'androiddebugkey'
                keyPassword 'android'
            }
        }
        buildTypes {
        debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-                        
       rules.pro"
      }
   }
}

dependencies {
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation("com.facebook.react:flipper-integration")

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

apply from: file("../../node_modules/@react-native-community/cli-platform-        
android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

我已经尝试了所有可能的解决方案,所有版本控制等。我可以得出结论,当我需要在 appcenter 中构建它时 classpath("com.facebook.react:react-native-gradle-plugin:--需要在此处指定版本"),需要指定版本然后也许可以解决这个问题,但我不知道哪个版本。我尝试过 0.71.19、0.66,但不确定是什么版本。

非常感谢这里的一些指导

谢谢你

android react-native android-gradle-plugin build.gradle
1个回答
0
投票

我询问了应用中心服务台并得到了答案。

  • 打开应用中心构建配置页面,然后启用环境变量并添加java的变量 JAVA_HOME 设置为 $(JAVA_HOME_11_X64)
© www.soinside.com 2019 - 2024. All rights reserved.