I have a problem building a RN project in android I run: yarn android and that's what I face:
I tried to clean the gradle: ./gradlew clean I also tried to delete the build in android: rm -rf android/app/build but none of these worked for me.
Any clue what's the problem or maybe solution?
try to open android folder on your project in android studio app, gradle will update automatically
Related
I am new to Ionic while build the app in android. Its opening a project in Android Studio but while gradle sync its showing the following error
Could not read script 'F:\IonicProjects\mis-tracking-master-latest\mis-tracking-master\mis-tracking\android\capacitor.settings.gradle' as it does not exist.
Try to sync your Ionic project by command:
ionic capacitor sync android
JUST DO
npx cap sync android
If you only use capacitor from (Vuejs, nuxtjs, etc.)
Same thing happen to me. I did a
npm install --save #capacitor/core #capacitor/cli
and this fixes it.
change the name of my file /android/settings.gradle to capacitor.settings.grandle works for me
just do
npm install jetifier
npx jetify
npx cap sync android
Capacitor troubleshooting
https://capacitorjs.com/docs/android/troubleshooting
Over folder project execute: $ capacitor update android
On Android Studio execute: File -> Sync Project with Gradle Files
run ionic build before you run npx cap add android
This is what solved it for me:
I'm using next/JS and I export it. So the build folder is not "build", it is "out".
Just go to the capacitor.config.json and change the webDir property to out
I try to get apk of app. I did it before well. However, I tried to use get apk of other app today but it doesnt give me release apk. why ?
I followed these steps : enter link description here
Normally, it takes 2-3 minutes but now it lasts just 3 sec and doesnt generate apk
it says this :
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.4.1/userguide/command_line_interface.html#sec:command_line_warnings
I had the same problem. Following command worked for me:
After the ./gradlew bundleRelease command we get a .aab version of our app. To get APK, you should run the app with release version on any device with the below command.
Make sure you have connected an android device
For the production ready app, firstly you have to remove the previous app from the device
Run this command in your-project/:
react-native run-android --variant=release
Then APK can be found in android/app/build/outputs/apk/release
Hope this helps
the short answer uses gradlew assembleRelease instead.
not short answer :) The command you are using gradlew bundleRelease builds an android App bundle. read this:
Difference between apk (.apk) and app bundle (.aab)
and this:
https://developer.android.com/guide/app-bundle
AAB file is new and not all stores support it.
Use gradlew bundleRelease to generate an app bundle (.aab file) and gradlew assembleRelease to generate an apk (.apk file). To install a release on your emulator, use react-native run-android --variant=release. I hope this helps
Cutting the long story short the command gradlew bundleRelease is used to generate an .aab file where as the command gradlew assembleRelease is used to generate .apk file so use the command accordingly
I made a file that called build.sh.
When i want to release a new version of android in ReactNative, just type and press sh ./build.sh in terminal.
My shell script in build.sh file:
npx jetify && cd android && ./gradlew clean && ./gradlew assembleRelease && ./gradlew bundleRelease && cd ..
You can simply open the Build Variants window on the bottom left hand corner of Android Studio and choose release as the current variant:
The following should solve your issue:
Open Android Studio and select "build bundle(s)" from Build/Build Bundle(s)/Apk(s)
Then, open your console and run
cd android && ./gradlew bundleRelease
from your project's root. You may encounter an error such as
Cannot add task 'wrapper' as a task with that name already exists., because overriding built-in tasks are deprecated in 4.8 and produces an error.
To prevent it, please update your android/build.gradle, as follows:
FROM:
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
TO:
wrapper {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
Lastly, don't forget to convert your .aab file to .apk through bundletool in order to test locally your app (exactly as an APK file)
step - 1) ./gradlew bundleRelease
step - 2) react-native run-android --variant=release
Make sure you have connected an android device
For the production-ready app, firstly you have to remove the previous app from the device
./gradlew app:bundleRelease Will fix your problem for sure.
good time.
run ios error Failed
run code
react-native run-ios
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening reactapp.xcodeproj
** BUILD FAILED **
I've got the same error when run
$ react-native run-ios
My workaround steps:
open project by Xcode and choose the signature information as the attached image.
clear build folder: 'Your Project'/ios/build
re-run:
$ react-native run-ios
Hope this help.
That's because there is a new version of Flipper and React Native might not come with the right one so best is to go in your podfile and add this use_flipper!({ 'Flipper' => '0.74.0' }) then run pod install
If you don't have cocoa pods installed you need to by command sudo gem install cocoapods and run following commands from your project main directory
cd ios
pod install
cd ..
delete build folder from ios
react-native run-ios
if error persists, 1. delete build folder again 2. open the /ios folder in x-code 3. navigate File -> Project Settings -> Build System -> change (Shared workspace settings and Per-User workspace settings): Build System -> Legacy Build System
cd ios
rm -rf build/
cd ..
react-native run-ios
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
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