代码之家  ›  专栏  ›  技术社区  ›  user3431310

AppCenter:无法解析com.facebook.areact:areact原生gradle插件

  •  0
  • user3431310  · 技术社区  · 2 年前

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

    `* 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)`
    

    项目级建筑.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"
    

    设置渐变

       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')
    

    爬坡特性

       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
    

    应用程序级构建.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.areact:areact native gradle plugin:--需要在此处指定版本”) ,需要指定版本,然后也许可以解决这个问题,但我不知道是哪个版本。我试过了,0.71.19,0.66,但不确定是什么版本。

    非常感谢这里的指导

    非常感谢。

    0 回复  |  直到 2 年前
        1
  •  0
  •   user3431310    2 年前

    我询问了appcenter服务台,得到了答案。

    • 打开应用程序中心构建配置页面,然后启用环境变量并为java添加变量 JAVA_HOME设置为$(JAVA_HOME_11_X64)