gpt4 book ai didi

android - 无法解析 org.webkit :android-jsc:+

转载 作者:行者123 更新时间:2023-12-05 09:29:18 42 4
gpt4 key购买 nike

每次尝试为我的 React Native 项目运行“react-native run-android”或“./gradlew bundleRelease”时,我都会遇到错误。

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:collectReleaseDependencies'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve org.webkit:android-jsc:+.
Required by:
project :app
> Failed to list versions for org.webkit:android-jsc.
> Unable to load Maven meta-data from https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml.
> Could not HEAD 'https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml'.
> Read timed out

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 37s

这是我的 build.gradle 文件:

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

buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 24
compileSdkVersion = 30
targetSdkVersion = 30
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "16.0.1"
}
repositories {
google()
mavenCentral()
mavenCentral()
}
dependencies {
classpath 'com.facebook.react:react-native:0.12.+'

classpath 'com.android.tools.build:gradle:4.0.0'
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 {
mavenCentral()
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")
}
maven {
// expo-camera bundles a custom com.google.android:cameraview
url "$rootDir/../node_modules/expo-camera/android/maven"
}
maven { url 'https://maven.google.com' }
maven { url 'https://www.jitpack.io' }

google()
jcenter()
}
}

我找不到任何关于为什么会发生这种情况的信息,除非添加“www.”。到 'https://www.jitpack.io' 但它已经有了。

'react-native run-android' 昨天还在运行,后来我换了模拟器,也换了java版本。

有人知道为什么会这样吗?

最佳答案

JCenter is going to shutdown现在是只读的。它经常脱机,导致构建和管道出现问题。

总结

您需要更新您的 android/build.gradle 文件以使用 mavenCentral() 而不是 Jcenter()

根据 Gradle 文档,JCenter 是 Maven Central 的镜像,因此您的所有依赖项都应该在那里。

JCenter is a central artifact repository, like Maven Central. Softwareprojects use JCenter to distribute their software to other people.JCenter also serves as a mirror for Maven Central, so any dependenciesavailable on Maven Central are also available on JCenter (but not viceversa).

需要考虑的几件事:

  • 如果它是一个指向 Jcenter 的(例如 node_modules/react-native-appsflyer),这会给您一个错误...我建议您检查给你一个错误的库已经更新了一个带有修复的新版本。如果是这样,请更新到新的版本以获取更改。

  • 如果库没有修复的版本,如果您使用 npm 包在 React-native 中构建,您可能会利用 patch-package library .因为库可能尚未发布从 build.gradle 中删除 JCenter 的更新。

应用补丁

您可以使用补丁包库自行应用更改。文档在最后添加以供引用。

  1. 转到 node_modules/library-with-error/android/build.gradle
  2. jcenter() 更改为 mavenCentral()
  3. 运行:npx patch-package library-with-error
  4. Git 添加、提交和推送

个人笔记:

  • 我确实建议完全删除 JCenter 而不是将 MavenCentral() 添加到顶部,因为 shutdown 而且 JCenter 经常脱机并出现超时错误。

Based on the current timeline, builds that use JCenter will be able toresolve dependencies until February 1, 2022 without changes. Afterthat date, there are no guarantees that you will be able to buildyour software if you continue to use JCenter."

  • 此外,Gradle 不鼓励使用 JCenter。

"To discourage new projects from using JCenter, we will be removingJCenter from our samples and init templates. The new default will beMaven Central. Gradle itself has no inherent tie to JCenter or MavenCentral, so you can always switch any other repository of your choice.This change will be effective with the next Gradle release – Gradle7.0."

有用的链接

  • --use-yarn 添加到 patch-package 命令,以防您的项目使用 Yarn .
  • 文档使用 Patch package .

关于android - 无法解析 org.webkit :android-jsc:+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70746440/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com