React Native app runs on emulator, not on device - javascript

The app runs perfectly on an emulator from Android Studio, but returns
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment
When I run it from the CLI
I've tried rerunning the command and creating a new project
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment

Follow the steps below in order to solve the issue:
Go to the root project folder.
Find the Android project (which the Android Studio would recognize)
Open it on Android Studio and fix all the Gradle-related issues.
Once there is no more issue, close Android Studio and rerun the
react command.

Related

Cannot run this React Native example in web browser

Code example I am trying to run: https://github.com/nshaposhnik/react-native-maps-example
I am on windows 10.
What I do:
Downloaded the code
Extracted to folder
Setup with the following after deleting yarn.lock:
yarn add react-native-maps
yarn add react-native-maps-directions
yarn add react-native-google-places-autocomplete
npm install
npm audit fix
Edit the code in the 3 places that requires my custom google API key which I got from the developer site
Tried running via:
npm start
I get a successful run in the terminal (" Welcome to React Native! Learn once, write anywhere"), but no browser opens up. I go to localhost:8081 in my browser and see a barren webpage with the following text:
React Native packager is running.
Visit documentation
That's all. Nothing in the sample project runs. I just want to run their app in a browser or emulator, though I don't have any of the phone emulators working, so I just want to run in web browser.
How can I make this work from the above example? Much appreciated.
You have to run emulator separately on "Windows" using android studio or command line, and after open your project using VsCode(or your editor) and the run following command ,
react-native run-android
Your app will run on your opened emulator

How to build react-native app for iOS properly?

I developed a react native app (version 57.4) on windows for android and it works fine.
Now I'm trying to build for iOS with no luck (as I don't have any experience with Xcode).
What I tried so far:
I knew that it requires a Mac and Xcode so I downloaded a VM, install Xcode.
Git clone myApp
react-native run-ios
But I got a lot of errors and build failures so after some search, I make these more steps:
react-native link
link some fonts manually
add a pod file and pod install
make some Xcode changes which I can't remember
react-native run-ios
And it works :)
BUT I had an issue with axios so I tried to fix it but I ruined the app so I removed the folder and re-cloned it again.
This time, I can't build successfully again!! and if it builds it crashes instantly!
My Question is what the exact steps do I need to make to build successfully on Mac (especially steps for Xcode)? including how to link all native dependencies correctly? and Is the pod file is necessary?

New project with react native but errors

My head is so pain right now, I just screw up my old project and not able to run currently, So I guess I just create a new react native project and transfer my code to it, guess what? I hit this error after my creation of react native and ran react-native run-android.
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug
Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
:app:transformClassesWithDexForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: dx.jar is missing
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.998 secs
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:
https://facebook.github.io/react-native/docs/getting-started.html
This multidex thing, I never set this before or anything previously on my 1st project like 1 week ago. With a new project, I can't even run my android emulator with react-native run-android for the 1st time.
Someone please help me to solve this issue please.
There are some common solutions for this issue. First of all you need to find your buildToolsVersion in gradle file.
To import react native project into android studio follow these steps.
Open Android Studio and click Open existing project
Find your project folder and inside that there will be folder called android
Open that folder with android studio
Make sure you have the newest android studio release.
If there is any build error just fix them simply by clicking the errors.
Once you have correctly build your project find build.gradle (Module:app) file under Gradle Scripts.
There you can see the buildToolsVersion of your current project. Change it like this
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
After that clean your android project using Build > Clean Project
Next rebuild your android project using Build > Rebuild Project
After that navigate your react native project folder and delete build folder.
It can be found here YourProject > android > app > build
Then before you run your react native project, note that Android Emulator is already running. If not run your android emulator using android studio
Finally run your react native project using react-native run-android

I can't run my react native code even though I have an emulator running in the back round

I am trying to run react native code but when I use react-native run-android I get this error message. I am using android studio.
~/Downloads/BrainG-master$ sudo react-native run-android
Scanning folders for symlinks in /home/luke/Downloads/BrainG-
master/node_modules (10ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew
installDebug)...
: No such file or directory
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:
Make sure
there is an android directory inside /Downloads/BrainG-master (I hope you're not running react-native run-android from within the android directory) and
your local.properties file in BrainG-master/android has the location of your android SDK specified in the following format: sdk.dir=/Users/username/pathToYourAndroidSdk.
If there is no local.properties file, open the project in Android Studio and it will create that for you.
If you're on Linux, you can also configure the android home environment thus:
Add the following lines to your $HOME/.bash_profile config file:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
.bash_profile is specific to bash. If you're using another shell, you will need to edit the appropriate shell-specific config file.
Type source $HOME/.bash_profile to load the config into your current shell. Verify that ANDROID_HOME has been added to your path by running echo $PATH.
You can follow the instructions here: https://facebook.github.io/react-native/docs/getting-started.html#2-install-the-android-sdk

platform-tools\adb.exe: Comman d failed with exit code 3221226356

When I run (Ionic run android )ionic project, it build success but there was an issue in deploying to device.
this is the error in my cmd
Follow below steps
Create virtual device from android adb manager.
Open virtual device(emulator).
Open termainal and check your emulator is connected or
not. $ adb devices.
If your emulator is connected then open
terminal and go to your root folder of project.
run followingcommand
$ ionic run android
I hope its work for you

Categories

Resources