Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 476
Romero Antonio Ramos de Mendon Avatar asked Apr 14 '21 13:04

Romero Antonio Ramos de Mendon


Video Answer


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

like image 60
J Myers Avatar answered Oct 19 '22 17:10

J Myers


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
like image 39
sainiankit Avatar answered Oct 19 '22 17:10

sainiankit


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

like image 4
Łukasz K. Avatar answered Oct 19 '22 18:10

Łukasz K.


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

like image 2
Matthijs De Cooman Avatar answered Oct 19 '22 19:10

Matthijs De Cooman


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.

like image 2
Sohail Shrestha Avatar answered Oct 19 '22 19:10

Sohail Shrestha


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.

like image 2
Maanli yass Avatar answered Oct 19 '22 17:10

Maanli yass


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

like image 1
SOG MH Avatar answered Oct 19 '22 19:10

SOG MH