Failed to intall the app in react native, how can I fix this? - react-native

I was trying execute myapp to android but an error occurred.
To clarify what happened, first time I install nodejs and Android Studio.
Later I used the following commands:
npx react-native init 'app'
cd app
npx react-native run-android
Its my fisrt time messing with react native, I was following this page:
https://learn.microsoft.com/pt-br/windows/dev-environment/javascript/react-native-for-android
And the error is:
The error
I want coding in real time for android app.
How can I fix this?

Looks like the terminal output gives you several steps to do/check.
Make sure you have properly set up your android environment. Use this link to do so. You can use Expo-Cli or React-Native-Cli.
SDK location not found. This could be an off-shoot error of not properly doing step 1. However, to cover all of your bases, ensure you have properly set up your Android Emulator. This doc is a great walkthrough.
Once your Android studio and AVD Manager is properly set up, and your development environment is properly set, you should have no issues!
Please let me know if doing the above to steps did or did not solve your errors.

If you follow the steps, https://reactnative.dev/docs/environment-setup and https://developer.android.com/studio/run/emulator there will be no problem.
As a React Native fan on Windows 10, I'd like to mention just few points you need to check.
First, please check following user variables in Environment Variables ( You can see it from System Properties).
adb="C:\Users{username}\AppData\Local\Android\Sdk\platform-tools"
ANDROID_HOME="C:\Users{username}\AppData\Local\Android\Sdk"
JAVA_HOME="C:\Program Files\OpenJDK\openjdk-11.0.15_10"
Path: check if contains {ANDROID_HOME}\platform-tools
Eg:"C:\Users{username}\AppData\Local\Android\Sdk\platform-tools"
Second, if you are using Android Sdk emulator, please make sure that it configured correctly in emulator list in Android Studio.
For an instance, I created a android emulator using android sdk-29 and you can check the followings.
Third, I recommend you, deploy first app on emulator in Android Studio.
Because we need to download gradle zip file and others, it's essential to run your first android app in Android Studio.
When you confirmed your first android app(Deploy empty project app is also okay), you can run your React Native App by Expo-cli or react-native-cli.

Related

Issue with Expo Image Picker at build time

This is the error I am facing at the time of building the ios for my expo app.
Here is the code for Image Picker I used
This is working great in my simulator expo app as well as in iphone expo as well but giving this error while building using eas build -p=ios
I try doing different things and after trying many things I get to know it's because of outdated verions I updated everything in my package.json with the help of expo doctor I see compatible and install them and it's fixed.

i successfully done my app and testing in expo. now how to install in real physical device?

i have successfully made and tested the application in expo. but i don't know how to install in physical device and i want to deploy it also. please help me.
while using react-native run-android showing this error.👇👇👇
Android project not found. Maybe run react-native android first?
If you are using expo, you should not have to make the build as a react native project. You can check in the following link the documentation in expo about how to build in Andrdoid/ios and get the apk/ipa:
https://docs.expo.io/versions/latest/distribution/building-standalone-apps/
In a summary, if you have the app.json correctly configured, you just have to run:
expo build:android
Hope it helps

Expo React-Native App doesn't work when run as a standalone APK

My Expo-based React Native App works without a problem when run in the Expo tool but gave the following errors when built as an APK to be installed and run standalone.
A series of white screens keep flipping before the blue screen comes up.
Here are my App.JSON and Package.JSON files
Package.json
App.json
And here are the screen capturing the error message.
Actually there are two ways to create a React Native application
create-react-native-app (CRNA)
react-native init
As you stated in comment section, You created your project using CRNA
CRNA will gave you some form of solid project structure, which is really useful for beginners to get started with react native, you code the app with pure javascript and the app will work inside Expo.
Now if you want to take build and run as a standalone apk for android,
There are two methods
You can run command: exp publish:android
You can eject your app from expo
Dont use exp publish for standalone apks,
You can use second method:
To eject your app:
First if you dont use any expo apis inside your apps, it is very easy to eject and build as a stand alone apk.
just do yarn eject
This will gave you some instructions and follow that.
After that your CRNA project structure will be converted into react-native init project structure, now you will be able to see "Android" and "iOS" folders inside your application
To take build Run: connect your phone with USB debugging ON and react-native run android.
That's all.
Solved my own problem. The 'eth-lightwallet' library works perfectly within the Expo development tool but when I build into an APK, it just made the white screen turns up with no meaningful error messages.
The solution is to replace it with a pure web3js implementation.
This may be useful if you are developing a mobile app for Ethereum.

Converting project to react native init

Firstly I created my project with create-react-native-app and I'm developing my app with npm start and I have expo installed on my emulator. How can I convert these project into react native init, I don't want to use expo anymore...I don't neeed any api-es from them...
Thank you
The best resource for this is in the create-react-native-app repository. Try having a look here to get started.
The short answer is to use npm run eject
If you have experience generating signed APKs for Android and code signing with iOS then you shouldn't run into too much trouble.
If you don't, then take the time to go through the Android docs and also this guide should help you get up on running on iOS as well.
Good luck!
Instead of creating your project using the command create-react-native-app, you may create a react native project by following "Building Projects with Native Code" of the getting start guide: https://facebook.github.io/react-native/docs/getting-started.html.
Here you will find out how to:
1. Set up the environment.
2. Installation of phone emulator.
3. Connection of your phone via USB for testing.
4. Create a project using the react-native init command.

Could not install the app on the device - react native on windows 10

Everytime I try to launch a react native project I got this error
Could not install the app on the device, read the error above for
details. Make sure you have an Android emulator running or a device
connected and have set up your Android development environment
I reinstalled nodejs, python and jdk using choco as suggested on official docs. Every single packages is installed as well as sdk 23.0.1
I can see my virtual device if I run adb devices USB debugging is activated and it's running android 6.
I setup ANDROID_HOME path in environment variables, I'm using same sdk path as you can see in the picture. I also setup another one for JAVA_HOME and Python.
My PATH looks like this:
I just don't understand what I'm supposed to do. I'm using a surface pro 4, Windows 10. I can run projects using expo. I literally tried everything, restart computer, start cmd using admin, create new virtual devices, uninstall everything and start from scratch, it just don't work.
You have pointed out two issues; first, make sure you have an android emulator running. To do that, you run adb devices and you say you can see you device.
The other issue is with the environment. To make sure your environment is setup properly for android, go to the root of your react-native project. Open the android project using android studio.
All errors with your environment will show up, use the automatic fixes provided by android studio. Clean the project in android studio. Close studio and go back to command line, run react-native run-android
Everything should work now.
When doing react-native start it will intentionally hang at "Loading dependency graph" (its not really hanging, its just waiting to receive build/bundle signals). This is correct. You have to open a second terminal then do react-native run-android.
If you get errors, then cd android in your project folder then run ./gradlew clean, then after that do another react-native start then react-native run-android.
Solution is to delete all java JDK and reinstall v8 / change JAVA_HOME to the new path.
Also changing gradle-wrapper.propertiesfile for each project you want to run
# update gradle to latest version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
Sometimes it dosen't compile with v4 so I have to use v3. React native is definitely confusing.
after install dan update environment JDK now I can install app on my device