我在运行昨天刚刚运行良好的Reactive原住民应用程序时遇到了问题。因此,我运行了以下命令:
npx react-native run-android -- --warning-mode=all
它提供的信息以以下内容开头:
> Task :react-native-async-storage_async-storage:generateDebugRFile FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
FAILURE: Build failed with an exception.
...
* What went wrong:
Execution failed for task ':react-native-async-storage_async-storage:generateDebugRFile'.
> Could not resolve all files for configuration ':react-native-async-storage_async-storage:debugCompileClasspath'.
> Failed to transform react-native-0.71.0-rc.0-debug.aar (com.facebook.react:react-native:0.71.0-rc.0) to match attributes {artifactType=android-symbol-with-package-name, com.android.build.api.attributes.BuildTypeAttr=debug, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: C:\Users\pangi\.gradle\caches\modules-2\files-2.1\com.facebook.react\react-native\0.71.0-rc.0\7a7f5a0af6ebd8eb94f7e5f7495e9d9684b4f543\react-native-0.71.0-rc.0-debug.aar.
> Java heap space
我的第一个问题是如何解决这个问题?我似乎无法在因特网上找到解决这一特定问题的办法。显然,它与‘异步存储’包有关,我确实对其进行了更新,但这并没有解决问题。
据推测,使用“-警告-模式=所有”语句应该提供指向Gradle的链接,以帮助解析我看不到的issue...however。我还注意到,在输出中提到了‘react本机-0.71’,但是我使用的是一个较低的version...not,如果这与问题有关。任何建议都很感激。
我的第二个问题比较笼统。为什么这种荒谬可笑的事情经常发生在“反应本地人”中?如前所述,上次我启动代码时,代码运行得很好。我不能对我的代码(或最小的代码)做任何改变,突然之间,代码被打破了,没有功能.不是我自己的错误,而是与我无关的一些npm包或其他原因(例如Gradle)。我从来没有见过,也没有见过imagined...that这样一个不可靠和“充满漏洞”的软件可以向公众发布。为什么像这样的问题总是发生在“反应本地人”中?这只是无能还是有更好的答案?我总是面对着无尽的沮丧和愤怒,因为这些做法给我带来了这个特定平台的问题。如果有人能解释为什么这个开发‘环境’充满了这些问题,我会非常感激。
发布于 2022-11-06 08:51:01
由于0.71.0-rc0
的发布,Android的构建将会失败。
将此修补程序添加到 -> build.gradle文件中,如下所示:
buildscript {
// ...
}
allprojects {
repositories {
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// ...
}
}
此修复程序将应用exclusiveContent
解析规则,强制使用resolution库的分辨率,以使用node_modules
内部的解析规则
如果上面没有解决您的问题,请尝试下面提到的方法2:使用不同的错误响应本机Android构建失败,过去几天代码没有任何更改,原因是ReactinativeVersion0.71.0-rc.0
发布于 2022-11-06 16:01:14
行动似乎愤怒和诚实,我确实理解为什么他是,我怀疑为什么他不应该。直到昨天,11月5日,当我运行npx反应--原生运行-android时,我才开始运行构建,直到昨天,这个错误才被发现。我花了将近24小时寻找解决方案,直到我偶然发现了这个问题。
根据“Thanhal”的说法,这个修复方法适合我。
我调整了安卓/build.gradle。这里是我的gradle文件和修复的全部内容。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
kotlinVersion = '1.6.0'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
// ------ Fix starts here
exclusiveContent {
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
// --------- Fix ends here
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")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
google()
maven { url 'https://www.jitpack.io' }
}
}
我希望这对外面的人也有帮助。
发布于 2022-11-10 13:17:01
最近,我修复了这个问题b,更新了Reacti原住民的版本。当我陷入这个错误时,我有了这个0.68.1版本。您可以在这里轻松地更新您的版本,如何从这里更新您的版本
之后,我通过运行这个命令来清除android。转到您的项目,一个android目录并运行以下命令
./梯度清洁
然后返回到项目并运行
npm安装
之后,从手机中卸载应用程序,并再次运行项目。
https://stackoverflow.com/questions/74333132
复制相似问题