(React Native):任务 ':app:generatePackageList' 执行失败
(React Native): Execution failed for task ':app:generatePackageList'
我正在生成一个我使用 React Native 开发的项目的 apk。但是当我运行命令./gradlew assembleRelease
时出现如下错误:
> Configure project :react-native-audio
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
> Task :app:generatePackageList FAILED
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\romer\ProjetoAP\Gravador\teste\Gravador_de_audio\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 131
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> argument type mismatch
* 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 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 24s
1 actionable task: 1 executed
PS C:\users\romer\ProjetoAP\Gravador\teste\Gravador_de_audio\android>
如何解决这个问题?
我只是 运行 遇到了同样的问题,并且能够查明它发生在我的系统上的原因。使用 --stacktrace
标志有助于弄清楚发生了什么,最终指向 react-native-community/cli
包。
扫描 react-native-community/cli
存储库中的问题和 PR 后,我发现此 PR https://github.com/react-native-community/cli/pull/1396 添加了对 Gradle 7.
的支持
我的系统上有 Gradle 7,降级到 Gradle 6,运行 gradle wrapper
,然后 ./gradlew clean
让我继续前进。
希望这能解决您的问题,或者至少让您了解如何在您的系统上追踪它!
+1降级到6。今天想升级一下,结果适得其反。
使用Gradle版本6.9
Here are the highlights of this release:
- This is a small backport release.
- Java 16 can be used to compile when used with Java toolchains
- Dynamic versions can be used within plugin declarations
- Native support for Apple Silicon processors
使用 Gradle Wrapper 更改版本。
./gradlew wrapper --gradle-version 6.9
在 gradle/wrapper/gradle-wrapper.properties 中用 https\://services.gradle.org/distributions/gradle-6.9-all.zip
替换 distributionUrl 为我解决了所有问题。感谢上帝
使用 npx react-native upgrade
将您的 react-native 版本升级到最新版本
我不得不从 JDK 1.8 升级到 11,但出现了这个错误。
感谢 J Myers 的回答,我发现我必须升级本机版本:https://github.com/react-native-community/cli/pull/1396
React Native*
的解决步骤
在您的 app -> build.gradle
中找到 apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
。
检查这行代码是否重复
注释掉其中一个。
这应该可以解决您的问题。
按照此处所述升级 @react-native-community/cli
解决了我的问题:https://github.com/react-native-community/cli#updating-the-cli
If you use lock files (yarn.lock or package-lock.json) - find all the
@react-native-community/cli prefixed entries, remove them, run yarn
install / npm install once again.
我没有降级,而是检查了第 131 行提到的 reactNativeModule
参数。
好像 ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
,字面意思不匹配
确实reactNativeModule
他的声明中没有括号。
所以我改变了:
ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
到
ArrayList<HashMap<String, String>> packages = this.reactNativeModules
.
我正在生成一个我使用 React Native 开发的项目的 apk。但是当我运行命令./gradlew assembleRelease
时出现如下错误:
> Configure project :react-native-audio
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 5.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.
> Task :app:generatePackageList FAILED
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Users\romer\ProjetoAP\Gravador\teste\Gravador_de_audio\node_modules\@react-native-community\cli-platform-android\native_modules.gradle' line: 131
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> argument type mismatch
* 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 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 24s
1 actionable task: 1 executed
PS C:\users\romer\ProjetoAP\Gravador\teste\Gravador_de_audio\android>
如何解决这个问题?
我只是 运行 遇到了同样的问题,并且能够查明它发生在我的系统上的原因。使用 --stacktrace
标志有助于弄清楚发生了什么,最终指向 react-native-community/cli
包。
扫描 react-native-community/cli
存储库中的问题和 PR 后,我发现此 PR https://github.com/react-native-community/cli/pull/1396 添加了对 Gradle 7.
我的系统上有 Gradle 7,降级到 Gradle 6,运行 gradle wrapper
,然后 ./gradlew clean
让我继续前进。
希望这能解决您的问题,或者至少让您了解如何在您的系统上追踪它!
+1降级到6。今天想升级一下,结果适得其反。
使用Gradle版本6.9
Here are the highlights of this release:
- This is a small backport release.
- Java 16 can be used to compile when used with Java toolchains
- Dynamic versions can be used within plugin declarations
- Native support for Apple Silicon processors
使用 Gradle Wrapper 更改版本。
./gradlew wrapper --gradle-version 6.9
在 gradle/wrapper/gradle-wrapper.properties 中用 https\://services.gradle.org/distributions/gradle-6.9-all.zip
替换 distributionUrl 为我解决了所有问题。感谢上帝
使用 npx react-native upgrade
我不得不从 JDK 1.8 升级到 11,但出现了这个错误。
感谢 J Myers 的回答,我发现我必须升级本机版本:https://github.com/react-native-community/cli/pull/1396
React Native*
的解决步骤在您的
app -> build.gradle
中找到apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
。检查这行代码是否重复
注释掉其中一个。
这应该可以解决您的问题。
按照此处所述升级 @react-native-community/cli
解决了我的问题:https://github.com/react-native-community/cli#updating-the-cli
If you use lock files (yarn.lock or package-lock.json) - find all the @react-native-community/cli prefixed entries, remove them, run yarn install / npm install once again.
我没有降级,而是检查了第 131 行提到的 reactNativeModule
参数。
好像 ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
,字面意思不匹配
确实reactNativeModule
他的声明中没有括号。
所以我改变了:
ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
到
ArrayList<HashMap<String, String>> packages = this.reactNativeModules
.