![](/img/trans.png)
[英]Execution failed for task ':app:checkDebugDuplicateClasses'. React Native
[英](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
package。
在掃描react-native-community/cli
repo 中的問題和 PR 后,我發現了這個 PR https://github.com/react-native-community/cli/pull/1396 ,它增加了對 Gradle 7 的支持。
我的系統上有 Gradle 7 並降級到 Gradle 6,運行gradle wrapper
,然后./gradlew clean
讓我繼續前進。
希望能解決您的問題,或者至少讓您了解如何在系統上追蹤它!
我沒有降級,而是檢查了第 131 行提到的reactNativeModule
參數。
看起來像ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
,實際上是不匹配的。
事實上, reactNativeModule
在他的聲明中沒有括號。
所以我改變了:
ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules
到
ArrayList<HashMap<String, String>> packages = this.reactNativeModules
。
使用 Gradle 版本 6.9
以下是此版本的亮點:
- 這是一個小的向后移植版本。
- Java 16與 Java 工具鏈一起使用時可用於編譯
- 動態版本可以在插件聲明中使用
- 對Apple Silicon 處理器的原生支持
使用 Gradle Wrapper 更改版本。
./gradlew wrapper --gradle-version 6.9
+1 降級到 6。我今天想做一些升級,但結果相反。
npx react-native upgrade
您的 react-native 版本升級到最新版本
我不得不從 JDK 1.8 升級到 11 並且發生了這個錯誤。
感謝 J Myers 的回答,我發現我必須升級 react native 版本: https://github.com/react-native-community/cli/pull/1396
用 gradle/wrapper/gradle-wrapper.properties 中的https\://services.gradle.org/distributions/gradle-6.9-all.zip
替換 distributionUrl 為我修復了一切。 感謝上帝
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
在您的應用程序中應用apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
app -> build.gradle
。
檢查這行代碼是否重復。
注釋掉其中之一。
這應該可以解決您的問題。
對我來說react-native
版本0.70.6
問題是由於@react-native-community/cli-platform-android
版本所以我只需要運行
yarn add @react-native-community/cli-platform-android
作為這里給
按照此處所述升級@react-native-community/cli
為我解決了這個問題: https://github.com/react-native-community/cli#updating-the-cli
如果你使用鎖定文件(yarn.lock 或 package-lock.json)——找到所有帶@react-native-community/cli 前綴的條目,刪除它們,再次運行 yarn install / npm install。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.