Reputation: 962
I've upgraded my ReactNative project from 0.59 to 0.61.2 iOS is building fine but in android i'm facing the issue in @react-native-community/cli-platform-android module.
My settings.gradle file
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
My build.gradle file
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
I get the following error while building the app.
> Task :app:generatePackageList FAILED
FAILURE: Build failed with an exception.
* Where:
Script '/Users/yashwanth_c/Documents/projects/MobileApp/node_modules/@react-native-community/cli-platform-android
/native_modules.gradle' line: 130
* What went wrong:
Execution failed for task ':app:generatePackageList'.
> ReactNativeModules$_generatePackagesFile_closure3
* 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 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 5m 21s
4 actionable tasks: 4 executed
As always i've cleaned the cache and deleted the node_module folder, tried many times but no luck. Also googled for more than a week but still not able to find a fix, any advice is appreciated.
Upvotes: 36
Views: 153523
Reputation: 1020
Install npm i @react-native-community/cli
, version should be 12.3.6
Upvotes: 0
Reputation: 1
I solved this problem by adding
android.enableConfigurationOnDemand=false
in gradle.properties file
Upvotes: 0
Reputation: 1
I solve this problem @react-native-community\cli-platform-android\native_modules.gradle' problem solution
yarn cache clean npm install -g react-native-cli npx react-native doctor yarn global add @react-native-community/cli npx expo prebuild yarn expo run:android
Upvotes: 0
Reputation: 229
I also faced the same issue, and the following commands solved my issue
npm install
cd android
./gradlew clean
Then run the project.
Upvotes: -1
Reputation: 1618
I was facing the same issue in React Native 0.61.0
. I have tried the below solution:
For macOS:
./gradlew --stop
./gradlew cleanBuildCache
For Windows:
gradlew --stop
gradlew cleanBuildCache
Check this link for more reference https://github.com/react-native-community/cli/issues/591
Upvotes: 19
Reputation: 1210
If your react-native app fails to install on an Android emulator,
try to go to
gradle-wrapper.properties
and update
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Make sure that gradle is updated to the stable and latest version according to what suits
Upvotes: 3
Reputation: 1
Just remove:
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
from the build.gradle file
Upvotes: 0
Reputation: 476
Recently faced this issue in a newer project react native 0.72.3. Below is how I resolved this issue.
Added @react-native-community/cli as dependency and then added resolutions object in my package.json file with version number same as @react-native-community/cli that got installed.
"resolutions": {
"@react-native-community/cli": "14.0.0-alpha.3",
"@react-native-community/cli-clean": "14.0.0-alpha.3",
"@react-native-community/cli-config": "14.0.0-alpha.3",
"@react-native-community/cli-debugger-ui": "14.0.0-alpha.3",
"@react-native-community/cli-doctor": "14.0.0-alpha.3",
"@react-native-community/cli-link-assets": "14.0.0-alpha.3",
"@react-native-community/cli-platform-android": "14.0.0-alpha.3",
"@react-native-community/cli-platform-ios": "14.0.0-alpha.3",
"@react-native-community/cli-server-api": "14.0.0-alpha.3",
"@react-native-community/cli-tools": "14.0.0-alpha.3",
"@react-native-community/cli-types": "14.0.0-alpha.3"
}
Upvotes: 0
Reputation: 27
i was facing same issue what helps me is delete "node_modules" install again "node_modules" using this cmd : npm i then go to android_studio go to Build -> Clean Project
Upvotes: 0
Reputation: 87
I encountered a similar issue when transitioning from Windows to macOS and had trouble running my React Native project. The root cause was related to executable permissions on the Gradle file. To resolve this issue, follow these steps:
Open your terminal and navigate to your project's root directory:
cd android
This command will take you to the 'android' folder within your project.
Grant execute permissions to the Gradle script using either of the following commands:
chmod +x ./gradlew
or
chmod +x gradlew
Return to the project's root directory:
cd ..
Try running your project again.
These steps should help you resolve any permission issues when running your project on macOS. It's a common issue when transitioning from Windows, and granting execute permissions to the Gradle script is the key to solving it.
Upvotes: 0
Reputation: 175
i was using pnpm
package manager and it was not downloading @react-native-community
packages including cli-platform-android
.
i used yarn
in it took care of it.
Upvotes: 0
Reputation: 52
I had the same problem because I switched branches. You can try removing these things and reinstalling the dependencies to solve the problem.
delelte these:
android\build
android\app\build
node_modules
yarn.lock
package.lock.json
re-execute yarn
yarn install
yarn android
Upvotes: 4
Reputation: 339
In my case, it is because the package name has move from AndroidManifest.xml
to build.gradle
. Solved it by adding the package name back to AndroidManifest.xml
Upvotes: 1
Reputation: 2150
Just go to your MainActivity.java
file located on
C:\...path...\..\android\app\src\main\java\com\appname\MainActivity.java
just remove any imports above package com.yourappname;
and put them below it as below
package com.driverapp; //nothing above of this line that says package com.xxx
import android.os.Bundle;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
...
Upvotes: 2
Reputation: 21
In my case I was using PNPM, so I had to manually install @react-native-community/cli-platform-android
Upvotes: 2
Reputation: 464
Did you try installing packages using yarn or npm install? i was facing the same issue then I realized I did not install all the dependencies.
Upvotes: 1
Reputation: 605
Delete "node_modules", "packagelock.json" folders and then
yarn add @react-native-community/[email protected]
cd android && gradlew clean
Upvotes: 7
Reputation: 12514
In my case I am working on Monorepo with 3 different apps using single code base.
// packages/myapp/android/app/build.gradle:78
project.ext.react = [
entryFile: "packages/myapp/index.js",
enableHermes: false, // clean and rebuild if changing
cliPath: "../../node_modules/react-native/local-cli/cli.js",
]
// Update with extra '../' to point to the root `node_modules`
apply from: "../../../../node_modules/react-native/react.gradle"
Upvotes: 0
Reputation: 817
I have also face the same kind of problem. I don't know but for some reason, in the node_modules
cli-platform-android
package folder was not showing.
Then I follow these steps, to solve the issue.
-> Remove `node_modules` folder
-> Remove `package-lock.json` file
-> Then install all the package again using `npm install`
-> Then `Rebuild the project in android studio`. That is how my issue was solved.
Upvotes: 6
Reputation: 1082
I'm working in a monorepo. The file exists, but it was in my project root's node_modules/@react-native-community
NOT the package node_modules
.
To fix this, I updated the paths
/android/settings.gradle : Line 2
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
/android/app/build.gradle : Line 225
apply from: file("../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Upvotes: 14
Reputation: 1285
I had same issues then i tried below command. it's worked for me. It's mean, mannually install the android cli package.
npm i @react-native-community/cli-platform-android
If anyone known another solution kindly share here.
Upvotes: 41