3.28.2022

React Native - Running ON Android

 Running on Android

To run our React Native templates on Android, simply follow these steps, in order:

  • Plug in your Android device or open an emulator
  • Open a Terminal window and run:
  • cd ~/path/to/template
  • yarn install && react-native run-android
  •  
  • Replace ~/path/to/template with the correct path to the folder where you extracted the archive downloaded from our server. To make sure you are in the right folder, you can run “pwd” to see the current path. It must be the folder with the template, otherwise the app won’t run.

That’s all. The app is now running on your Android device. 

If you need more details or help, read on.  

Note: DO NOT open the project in Android Studio

Most of the times Android Studio will alter the project and you won’t be able to make it work. 

If you already opened the project in Android Studio, please download the template again and re-run it from a fresh unmodified copy, that was never opened in Android Studio.

 

 

Plug in an ANDROID emulator or device

In order to run React Native apps on Android, you need an Android device or an emulator. 

If you have an Android phone or tablet, simply plug it in. You might need to enable USB debugging in Device Settings, under Developer Tools. 

 

Follow the official Android documentation if you run into any issues. Android emulators are bundled into Android Studio, so please install Android Studio, open it, go to Tools -> AVD Manager and start an emulator of your choosing:

 

 

You can also create new emulators of your own, with your own hardware requirements. Once you have an emulator up and running, proceed to the next step.

 

 

 Run the React Native app

 

MacOS / UNIX All you need to do is simply run the two commands we described above:

  1. cd ~/path/to/template
  2. yarn install && react-native run-android

Alternatively, you can also use Visual Studio Code, which gives you a Terminal that’s directly located at the right folder. In that case, you can simply run “yarn install && react-native run-android” and the app will just start.  

Windows users The command prompt on Windows is weird, so don’t use it. Instead, please install Visual Studio Code, which has a built-in Terminal that behaves exactly like the terminal on MacOS. Go to View -> Terminal to activate the Terminal:

 


Please make sure you find the correct path of the folder where the template resides. 

Here’s an example of a commands sequence you can use as an example to locate the correct folder: 

 


 
 

 

 


 

 

3.23.2022

React Native - Errors. ( Default problems )

When Standard Programming happens ... at the beginning or our daily lives

React Native Errors -  Attention 

1. Error: Activity class {com.appname/com.appname.MainActivity} does not exist.

Despite the message, this is in fact NOT AN ERROR.

As long as you got the successful green message “BUILD SUCCESSFUL” 

(see image below), you can manually open the app on the device/emulator on which you built the project. Just find the app icon and tap on it. That will open the app.










2. Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

If you’re running into this issue, it’s because you’re missing this file: android/gradle/wrapper/gradle-wrapper.jar .

You can generate this binary by simply running

  1. gradle wrapper

in the project’s android folder. If you don’t have gradle installed, follow gradle documentation on how to install it (or just run “brew install gradle” on MacOS).



3. Attention : No bundle URL present

If you’re getting this error, it means your packager server didn’t start. 

You’ll have to start it manually by running

  1. npm start -- --reset-cache


Once the metro bundler started, simply reload the project.


4. SDK Location not found

If you’re running into this issue when building a React Native mobile app on Android, it’s because your Android SDK path is broken or it doesn’t exist. Open your ~/.bash_profile, and add the following lines at the beginning:

  1. export ANDROID_HOME=~/Library/Android/sdk/
  2. export PATH=~/Library/Android/sdk/tools:$PATH
  3. export PATH=~/Library/Android/sdk/platform-tools:$PATH

 

 

Now load the new ~/.bash_profile in your Terminal (restart the Terminal or run “source ~/.bash_profile“), and re-run the Android app.






Node.js?

  Node.js? It is JS or Javascript yes, it is the basis.  Yes the old Javascript that today has a strong front and back end stack, the same s...