cannot able to run react native project by android emulator - react-native

Error when try to run
I am having react native project and iam trying on android emulator via below command
react-native run-android
but its not working getting the error like in the image

From your log, it's clear that you haven't configured SDK location
You must add SDK location
sdk.dir=/Users/XXXXX/Library/Android/sdk
Create a new file named local.properties inside the android folder of your react-native app.
Add the SDK location.
Hope this helps

Related

A problem occurred configuring project ':#sentry_react-native' SDK location not found

I'm on MacOS trying to run a react native (0.59.9) app on Android emulator. I've integrated Sentry using the wizard. Works fine on iPhone. On Android, this happens:
I try to run the app w/ react-native run-android
Build fails.
A problem occurred configuring project ':#sentry_react-native'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
I go into the android folder and create a local.properties file and paste this in:
sdk.dir=C:/Users/my_name/Library/Android/sdk
I try again to run the app w/ react-native run-android
Build fails.
A problem occurred configuring project ':#sentry_react-native'.
The SDK directory '/Users/my_name/project_path/android/C:/Users/my_name/Library/Android/sdk' does not exist.
Why is it concatenating the SDK dir w/ my project path? That doesn't make sense to me. How do I fix this?
this isn't a Sentry issue, but an Android environment issue, please look at https://reactnative.dev/docs/getting-started.html and set your Android env. properly.
Look for "Android development environment", good luck :)

How to fix React-Native Error 'could not unzip gradle-5.4.1-all.zip'

I have created a project HelloWorld in react native by using react-native init HelloWorld
When I run the project by using react-native run-android command, i am facing error
could not unzip gradle-5.4.1-all.zip
I have tried the following
1.updated react native
2.wipe the data from Emulator.
To resolve this kind of error the following steps are used
Open My computer.
Navigate the following folder
C:\Users\UserName.gradle\wrapper\dists
Delete the 'gradle-5.4.1-all.zip' folder
Run React-native project by using react-native run-android command.
The system will download updated gradle-5.4.1-all.zip file so
internet connection must be ON

React Native Expo publish to Android

I built a test application using react native. I'm trying to publish it following this tutorial: https://facebook.github.io/react-native/docs/signed-apk-android.html
However, my project does not have folder android. How can I create this folder?
In React-native, there are two method to create Singed APK File
First you should know
it's best to create apps using react-native init rather than expo as React-Native-Cli gives you local project for both ios and android,you can test and debug the code locally and also use the tool to publish applications
- If you create the project by using this command -
react-native init Project_Name
Then follow this method.
BUT IN YOUR CASE
you're using expo and also expo-cli! that's good! but when i use expo i usually like to go with expo XDE which has single version to publish,render or debug with it's own console in the bottom and that'll help you upload your code to expo server where you can ask them to render app for iOS or android and they will return you a link which will download the APK or the ipa file for android or iOS respectively
Here is the documentation link which'll explain you each step one by one and do keep an eye on the notes and TODOs while following the step (in your scenario)
- If you use expo,for create React-native project
then follow this method generate the singed APK file for Android - Expo

How to set canOverrideExistingModule=true in React Native?

I build an android app using React Native,build got success but when i run app in my AVD it show up a error:
How can I fix this issue?
What you can try is first remove the duplicate declarations in method getPackages() of your MainApplication.java file.
If you're using Android Studio this file is in app > java otherwise you can find it in android/app/src/main/java/com/yourAppName/yourProjectName/MainApplication.java.
Then try again react-native run-android

how to run react native code from server? i want to release app in android and apple store

I am an android developer and learning react native.
I made an app in React Native and now I want to release my app in android play store and apple store but I don't know where do I put my react native project code/files?
I had put react native code in my PHP(Linux) server but it's not working, it says file not found 404.
please guide, Thanks
You need to generate build standalone signed apk.
Generating Signed APK
https://facebook.github.io/react-native/docs/signed-apk-android.html
1) first create keystore file and put in android folder location
2) setting up gradle for keystore
3) run comman
react-native run-android --variant=release
after success run command you will file apk-release.apk in andorid/app/build/outputs/apk/ location
then you can uplaod apk to app store
If your app doesn't need detach (for example doesn't use bluetooth) you can use create-react-native-app and put your app code inside new project. That way you can publish your app to https://expo.io/ . It's a great way to publish your app without Google Play and App Store.
Here is instruction for creating new react native app with expo kit:
https://facebook.github.io/react-native/docs/getting-started.html
And here is how to publish it into expo:
https://docs.expo.io/versions/v25.0.0/guides/publishing.html#how-to-publish
All you need is create-react-native-app and exp command line tools.