Task :react-native-location:compileDebugJavaWithJavac FAILED while building apk - react-native

I'm trying to build my apk & I'm getting this error while building my release apk in react native. Is there any way to fix this react-native-location error?

I was facing this issue while building my apk in react native. To solve this issue you need to:
1- cd android and then ./gradlew clean
2- then in your root directory run yarn jetify or npx jetify

Related

Install react-native-firebase/app#15.1.1 for ios set up and pod install and run npx react-native run-ios OR build from Xcode BUILD FAILED

Following the official documentation in react native firebase/app#15.1.1 it gives me the build failed error for terminal using the npx react-native run-ios and also from xcode builed both failed to build ...Can someone Provide me the installation for react-native firebase/app along with it react-native firebase/messaging and pushnotification/ios ..i am new to react-native Please help...

Not able to build ract-native .apk

project directory: cd android
./gradlew bundleRelease
react-native run-android is working fine, which means dev apk is working on device but, release apk is not build and failed with the above error.
How I can solve this issue?

"react-native eject": Unrecognized command "eject"

I am trying to recreate ios and android folders for my react-native project. As far as I know this is done with the command:
react-native eject
But I get the error:
error Unrecognized command "eject".
I am doing something wrong? How should I recreate android and ios folders?
react-native-cli: 2.0.1
npm i react-native-eject
npm i #react-native-community/cli
react-native eject
will generate the both android and ios folder
It did work in 0.59.9. This threw me too this morning after I upgraded to 0.60. Apparently you now have to run react-native upgrade --legacy true. react-native eject was much easier IMHO.
yarn add react-native-eject
react-native eject
This two-line of code solved my problem with the eject error.
Nikita is 100% correct. If the project was initialized in expo running react native eject will "eject" the project from the expo dependencies (and expo environment) and create a standalone react native project outside the expo environment. This typically adjusts the dependencies in the pakage.json file.
The command exists as a part of expo.
To initialize a project from scratch react-native init will create android and ios folders. Also ensure if you have cloned the directory to run either npm install or yarn to install the dependencies.
If the project was initialized the way I imagine yours was the commmand you are looking for would be one of the following:
react-native run ios or react-native run ios --device
react-native run android or react-native run android --device
For RN projects, which are initiated by react-native init there is no such command, by default RN is using metro bundler instead of web-version of React, where you can configure Parcel/Webpack/Rollup or run create-react-app where actually you can eject.
This question is suitable for expo where you can actually eject, if you need some native modules that are not included in expo.
Try to use expo
react-native eject and upgrade --legacy true aren't working for me.
In the end, I just created a new blank RN project and this had an ios folder. Copied the folder over to my existing project and ... seems to work.
Run npm i react-native-eject
Run npm i #react-native-community/cli --force
Note: use npx instead of npm
npx react-native eject
cd android
./gradlew.bat installDebug
cd..
npm run android

React native error, Execution failed for task ':app:processDebugResources'

Any ideas what this error means?
When I try and run, npm run playground-android, I get the error.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
java.io.IOException: Could not delete path 'C:\sites\ReactMatt\lower-your-drinking\android\app\build\generated\source\r\debug\org\webkit'.
Any ideas?
I one had similar issues. Below is how I fixed it.
cd android //Navigate into the android folder from the root directory
./gradlew clean // Run this
I hope it helps
On windows
i resolved by
1. cd android
2. ./gradlew clean
Try to close Android Studio while building through the CLI
I had this same problem but gradlew clean did not resolve issue until I removed the android and ios folders from my project and then used these commands;
react-native eject
react-native link
react-native run-android
good luck.
This works for me!
1) Navigate to android : cd android
2) Then run this command: ./gradlew clean
In your project,
Navigate to android => cd android
Then, run this command => ./gradlew clean
Then, open your project's Android kloser from Android Studio and Build Gradle

How to rebuild the entire Android folder?

I have messed the files up in the Android folder and would like to rebuild the Android project inside of the Android folder. How do I do this?
Is it safe to delete the Android folder and then run react-native run-android, will that make it again?
Everything I've coded was wrote in index.android.js.
EDIT: Original answer was written in 2017 (RN v.0.47?). React-native environment evolved and AFAIK this solution is no longer valid.
Probably safe to remove.
I had similar problem, and ./gradlew clean
didn't work, but i found hacky solution from How can I regenerate ios folder in React Native project?
Delete android folder (probably ios too), and then hacky part ->:
react-native upgrade
(it regenerates folders, but it shouldn't be used to upgrade RN..)
And then
react-native link
react-native run-android
It worked for me :)
EDIT : one observation -> react-native sometimes goes crazy and cannot run some commands. Launching a new terminal helps. Bizarre :)
The solution if ur version of react-native >= 0.61.0 :
sudo rm -rf android/ ios/
yarn add react-native-eject
npx react-native eject
enjoy !
Try to do this:
cd android
gradlew clean
cd ..
react-native run-android
Here my solution: (I'm doing this for android)
First command:(Navigation to the Android folder of your react-native project)
cd Android
Second command:
./gradlew clean
Third commmand:
./gradlew cleanBuildCache
I'm not fan of deleting android folder. (I think this not a best approaches)
To generate apk file for production: (First one from /Android)(second one from root project)
./gradlew bundleRelease
react-native run-android --variant=release
Happy coding!!!
Running following commands should do the trick:
sudo rm -rf android/ ios/ #Delete Android and ios folders first...
react-native eject
react-native upgrade //rebuilds android/ios folders
react-native link
react-native run-android
react-native run-ios
Below command will create the android and ios folders.
react-native eject
EXPO users: If you've used Expo then you can run expo run:android
If the folder is malformed (or not present) it will clear and rebuild.
Yes, it is safe to delete the Android and IOS folder and you can make it again by following steps:
1.First Method:
react-native eject <=0.59.0
React-native had this command in the previous version. Running this command will check if the ios and android directories exist and then rebuild whichever one is missing.
sudo rm -rf android/ ios/
react-native eject // Will create new Android and IOS folder.
react-native link
react-native run-android
2.Second Method:
react-native upgrade --legacy true>=0.60.0
Now you should use the react-native upgrade --legacy true command to back up your android folders or ios as the case may be as this command will replace your files.
Funny solution here
Create a new react native app and copy the new android folder over and then run $react-native run-android
In 2022 January:
I am using windows.
Inside my VS code terminal:
rm android/
But to delete Android and ios folders first you do "rm android/ ios/"
It may warn you of your action, accept.
Next:
npm run android //rebuilds android/ios folders
npm run ios //rebuilds android/ios folders