我正在尝试编译一个在 react-native v6.2.2 中开发的应用程序。我遇到的问题是我已经安装了react-native-nested-scroll-view,但是当我运行 npm run androd 时出现以下错误:
失败:构建失败并出现异常。
无法解析配置“:react-native-nested-scroll-view:classpath”的所有工件。 找不到 com.android.tools.build:gradle:2.3.3。 在以下位置进行了搜索: - https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.3/gradle-2.3.3.pom 如果您尝试检索的工件可以在存储库中找到,但没有“Maven POM”格式的元数据,则需要调整存储库声明的“metadataSources { ... }”。 要求者: 项目:react-native-nested-scroll-view
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
build.gradle 文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
buildscript {
ext {
buildToolsVersion = "33.0.3"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
playServicesVersion = "17.0.0"
androidMapsUtilsVersion = "2.2.0"
supportLibVersion = "28.0.0"
agp_version = '4.2.0'
kotlin_version = "1.5.31"
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:$agp_version")
//classpath("com.android.tools.build:gradle:2.3.3")
classpath('com.google.gms:google-services:4.3.5')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
configurations.all {
resolutionStrategy {
// Remove this override in 0.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
repositories {
google()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
package.json “react-native-nested-scroll-view”:“^9.0.0”,
我添加了内部依赖项 classpath('com.android.tools.build:gradle:2.3.3') 我有更多存储库,例如 google、mavenCentral 和 maven 我已删除节点模块文件夹并运行 npm install
看看这个 StackOverflow 问题,它返回相同的错误,但情况不同。这可能是同样的根本问题。
我个人认为你必须将你的
distributionUrl
更改为正确的版本。
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
到
distributionUrl=https\://services.gradle.org/distributions/gradle-2.3.3-bin.zip