(React Native): Execution failed for task ':app:generatePackageList'

Viewed 22604

I am generating an apk of a project that I developed using React Native. But when I run the command ./gradlew assembleRelease The following error appears:

> 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>

How to solve this problem?

8 Answers

I just ran across the same problem and was able to track down why it was happening on my system. Using the --stacktrace flag helped to figure out what was going on, which ended up pointing to the react-native-community/cli package.

After scanning the issues and PRs in the react-native-community/cli repo, I found this PR https://github.com/react-native-community/cli/pull/1396 which adds support for Gradle 7.

I had Gradle 7 on my system and downgrading to Gradle 6, running gradle wrapper, then ./gradlew clean allowed me to move on.

Hope that solves your issue, or at least gives you some insight on how to track it down on your system!

Use Gradle Version 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

Use Gradle Wrapper to change the Version.

./gradlew wrapper --gradle-version 6.9

+1 for downgrade to 6. I wanted to do some upgrades today, but ended up opposite.

Upgrade your react-native version to the latest one with npx react-native upgrade

I had to upgrade from JDK 1.8 to 11 and this error occurred.

Thanks to J Myers answer I found that I had to upgrade the react native version: https://github.com/react-native-community/cli/pull/1396

Steps to solve it for React Native*

  1. Find apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) in your app -> build.gradle.

  2. Check if this line of code is being repeated.

  3. Comment out one of them.

This should solve your issue.

Replacing distributionUrl with https\://services.gradle.org/distributions/gradle-6.9-all.zip in gradle/wrapper/gradle-wrapper.properties fixed everything for me. Thank GOD

Instead of downgrading, I checked the reactNativeModule parameter mentioned at line 131.

It seems like ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules, there is literally a mismatch.

Indeed reactNativeModule doesn't have brackets in his declaration.

So I changed :

ArrayList<HashMap<String, String>>[] packages = this.reactNativeModules

to

ArrayList<HashMap<String, String>> packages = this.reactNativeModules.

Upgrading @react-native-community/cli as described here solved the issue for me: 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.

Related