DEV Community

Cover image for Run React Native Android App On Mac M1
Ravi Sharma
Ravi Sharma

Posted on

Run React Native Android App On Mac M1

Hi Guys Ravi here...
So many people asking about running the android app on mac m1 system and about its performance on mac m1. So In this post I am sharing all steps to run the react-native android app on mac m1.

Android Emulator for M1 is not available on stable releases yet and I am also waiting for Android Studio to fully support M1 macs so that I can use it for developing my React Native project.

But!

Android Studio Preview has supported M1 chips pretty well so I am using that one to test my android app.

(You can also watch full video on this topic :
https://youtu.be/yOErAwnu4pc)

You can download Android Emulator for M1 from the below link:
https://github.com/google/android-emulator-m1-preview/releases/tag/0.3

1.Setup M1 Android Emulator:
You can watch my video on Android Studio Setup on Mac M1:
https://youtu.be/3clEUFzXPjA

Running Android Emulator

2.After Setting Android Emulator On Mac M1 edit your bash_profile. To edit it open your terminal and run below command

open ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

Add this line to your bash_profile, and replace the user-name with your username

export PATH="$PATH:/Users/user-name/Library/Android/sdk/platform-tools"
Enter fullscreen mode Exit fullscreen mode

Android Studio Environment Variable Setup
save and close. Run this command to reload your bash_profile

source ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

3.Then In Terminal check available adb devices by running below command:

adb devices
Enter fullscreen mode Exit fullscreen mode

It will show your Android Emulator
Listed Android Emulator

4.Now Create React Native Project by running below command

npx react-native init AndroidApp
Enter fullscreen mode Exit fullscreen mode

5.Once the project is created, Go to your react-native Project then go to android directory Create a file with following name "local.properties".

Open the file and paste your Android SDK path like below:

sdk.dir = /Users/USERNAME/Library/Android/sdk
Enter fullscreen mode Exit fullscreen mode

local.properties

6.Now run your react native project by

npx react-native run-android
Enter fullscreen mode Exit fullscreen mode

7.Now Your app will run in Android Emulator

Running RN Android App

Watch full Video here:
https://youtu.be/yOErAwnu4pc

If you have any question or facing any issue you can ask me.
If you like this post hit like button.
Thanks for reading this post.

Top comments (1)

Collapse
 
emrekorpe profile image
EmreKorpe

hi ravi,

I installed it on my macbook pro computer with m1 chip by following all the steps you specified. IOS works fine on the emulator, but the android keeps crashing.

  • What went wrong:
    Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at help.gradle.org

    at makeError (/Users/emrekorpe/Desktop/App/tester/node_modules/execa/index.js:174:9)
    at /Users/emrekorpe/Desktop/App/tester/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async runOnAllDevices (/Users/emrekorpe/Desktop/App/tester/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:106:5)

    at async Command.handleAction (/Users/emrekorpe/Desktop/App/tester/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)

    I have tried many versions such as android studio and gradle for days, but I have not been successful.
    Android Studio : Arctic Fox 2020.1.3
    Gradle : 7.0.2
    Gradle Wrapper Properties : 7.0.2-all.zip
    I researched and tested many solutions like stopping daemon.I look forward to helping you. thanks