无法应用插件“com.facebook.react.rootproject”

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

我尝试在我的模拟器上构建开发版本,昨天效果很好。但今天我遇到了这个错误:

  • 出了什么问题: 评估根项目“Displio”时出现问题。

无法应用插件“com.facebook.react.rootproject”。 配置项目“:app”时出现问题。 无法加载构建文件的已编译类

构建.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'

        ndkVersion = "25.1.8937393"
    }
    repositories {
        mavenCentral()
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle')
        classpath('com.facebook.react:react-native-gradle-plugin')
    }

}

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

allprojects {
repositories {
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url(new File(\['node', '--print', "require.resolve('react-native/package.json')"\].execute(null, rootDir).text.trim(), '../android'))
}
maven {
// Android JSC is installed from npm
url(new File(\['node', '--print', "require.resolve('jsc-android/package.json', { paths: \[require.resolve('react-native/package.json')\] })"\].execute(null, rootDir).text.trim(), '../dist'))
}

        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }

}

我尝试基本上浏览所有 gradle 文件以查找可能导致此错误的原因,但运气不佳

已解决:

出于某种原因,一夜之间我的电脑决定将 gradle-wrapper.properties 中的 gradle 版本从 8.6 更改为 8.3

gradle-wrapper.properties

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

将其更改为版本8.6,现在它通过了构建

javascript android reactjs react-native gradle
1个回答
0
投票

已解决

出于某种原因,一夜之间我的电脑决定将 gradle-wrapper.properties 中的 gradle 版本从 8.6 更改为 8.3

gradle-wrapper.properties

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

将其更改为版本8.6,现在它通过了构建

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