多个项目 react-native android 构建错误
Multiple projects react-native android build error
这是两个不同项目的 android/build.gradle 文件内容。
项目 1
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 30
supportLibVersion = "29.0.0"
googlePlayServicesVersion = "16.0.0"
firebaseVersion = "17.3.4"
firebaseMessagingVersion = "20.2.1"
firebaseBomVersion="20.2.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath ("com.google.gms:google-services:4.2.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
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")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
项目 2
buildscript {
ext {
kotlin_version = '1.5.0'
buildToolsVersion = "29.0.2"
minSdkVersion = 24
compileSdkVersion = 29
targetSdkVersion = 29
androidXCore = "1.7.0"
googlePlayServicesAuthVersion = "16.0.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.4")
classpath 'com.google.gms:google-services:4.3.10'
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 {
repositories {
mavenLocal()
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")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
当我执行:react-native-android,我得到以下错误。
项目 1
* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.facebook.android:facebook-login:[5,6).
Required by:
project :app
> Failed to list versions for com.facebook.android:facebook-login.
> Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-login/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/com/facebook/android/facebook-login/maven-metadata.xml'.
> org.apache.http.client.ClientProtocolException (no error message)
项目 2
* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.facebook.android:facebook-login:[8.1).
Required by:
project :app
> Could not resolve com.facebook.android:facebook-login:[8.1).
> Could not get resource 'https://jcenter.bintray.com/com/facebook/android/facebook-login/%5B8.1)/facebook-login-%5B8.1).pom'.
> Could not GET 'https://jcenter.bintray.com/com/facebook/android/facebook-login/%5B8.1)/facebook-login-%5B8.1).pom'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.facebook.android:facebook-android-sdk:9.0.
Required by:
project :app
> Could not resolve com.facebook.android:facebook-android-sdk:9.0.
> Could not get resource 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/9.0/facebook-android-sdk-9.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/9.0/facebook-android-sdk-9.0.pom'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.facebook.android:facebook-android-sdk:9.0.+.
Required by:
project :app > project :react-native-fbsdk-next
> Failed to list versions for com.facebook.android:facebook-android-sdk.
> Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
请注意,我检查了以下解决方案,但 none 有效
您的某些 android 依赖项似乎在 Jcenter 存储库中。
不幸的是,Jcenter 是 currently down。
你现在有两个选择:
- 等待jcenter up(目前已经down了4天)
- 迁移以使用其他东西。看:
- https://developer.android.com/studio/build/jcenter-migration
- Bitrise: Could not resolve all artifacts for configuration ':classpath' Could not resolve com.google.gms:google-services:4.2.0
就像 Gkueny 所说的那样,Jcenter 似乎宕机了。
我按照这个 link 再次获得了我的 React-Native 项目 运行。通过从我的 build.gradle 中删除 jcenter() links 并用 MavenCentral()
替换它们来修复
这是两个不同项目的 android/build.gradle 文件内容。
项目 1
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 30
supportLibVersion = "29.0.0"
googlePlayServicesVersion = "16.0.0"
firebaseVersion = "17.3.4"
firebaseMessagingVersion = "20.2.1"
firebaseBomVersion="20.2.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath ("com.google.gms:google-services:4.2.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
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")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
项目 2
buildscript {
ext {
kotlin_version = '1.5.0'
buildToolsVersion = "29.0.2"
minSdkVersion = 24
compileSdkVersion = 29
targetSdkVersion = 29
androidXCore = "1.7.0"
googlePlayServicesAuthVersion = "16.0.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.4")
classpath 'com.google.gms:google-services:4.3.10'
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 {
repositories {
mavenLocal()
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")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
当我执行:react-native-android,我得到以下错误。
项目 1
* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.facebook.android:facebook-login:[5,6).
Required by:
project :app
> Failed to list versions for com.facebook.android:facebook-login.
> Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-login/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/com/facebook/android/facebook-login/maven-metadata.xml'.
> org.apache.http.client.ClientProtocolException (no error message)
项目 2
* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.facebook.android:facebook-login:[8.1).
Required by:
project :app
> Could not resolve com.facebook.android:facebook-login:[8.1).
> Could not get resource 'https://jcenter.bintray.com/com/facebook/android/facebook-login/%5B8.1)/facebook-login-%5B8.1).pom'.
> Could not GET 'https://jcenter.bintray.com/com/facebook/android/facebook-login/%5B8.1)/facebook-login-%5B8.1).pom'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.facebook.android:facebook-android-sdk:9.0.
Required by:
project :app
> Could not resolve com.facebook.android:facebook-android-sdk:9.0.
> Could not get resource 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/9.0/facebook-android-sdk-9.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/9.0/facebook-android-sdk-9.0.pom'.
> org.apache.http.client.ClientProtocolException (no error message)
> Could not resolve com.facebook.android:facebook-android-sdk:9.0.+.
Required by:
project :app > project :react-native-fbsdk-next
> Failed to list versions for com.facebook.android:facebook-android-sdk.
> Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
请注意,我检查了以下解决方案,但 none 有效
您的某些 android 依赖项似乎在 Jcenter 存储库中。
不幸的是,Jcenter 是 currently down。
你现在有两个选择:
- 等待jcenter up(目前已经down了4天)
- 迁移以使用其他东西。看:
- https://developer.android.com/studio/build/jcenter-migration
- Bitrise: Could not resolve all artifacts for configuration ':classpath' Could not resolve com.google.gms:google-services:4.2.0
就像 Gkueny 所说的那样,Jcenter 似乎宕机了。
我按照这个 link 再次获得了我的 React-Native 项目 运行。通过从我的 build.gradle 中删除 jcenter() links 并用 MavenCentral()
替换它们来修复