简体   繁体   中英

Can't able to run react native application on android device

Im Using MacBook Pro.. Im New To React Native.. After Creating An Project Im Running On iOS Device It's Running.. At The Same Time While I'm Running On Android Device Means Im Getting This Error.. Any One Please Help Me To Resolve This Error.. Im Using Visual Studio Code IDE For React Native Application

Thanks In Advance..

Error Details :

[Info] local.properties file doesn't exist. Using Android SDK location from PATH.

[Info] Starting React Native Packager.

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 8 workers...
/bin/sh: adb: command not found
info Launching emulator...

error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

FAILURE: Build failed with an exception.

* Where:
Settings file '/Users/manikandan/AwesomeProject/android/settings.gradle'

* What went wrong:
Could not compile settings file '/Users/manikandan/AwesomeProject/android/settings.gradle'.
startup failed:
  General error during semantic analysis: Unsupported class file major version 57

So you have two errors to fix here as your error log

  1. local.properties file doesn't exist.
  2. Failed to launch the emulator

local.properties file issue fixing

  1. Open your react native project android folder using Android Studio.
  2. Wait for gradle sync and clean the project and rebuild it using Android Studio

在此处输入图片说明

  • After that make sure you have local.properties file is been created inside android folder

  • If not try these steps to make local.properties file manually

Right click top level of project and Create new file 'local.properties' then add: sdk.dir=/Users/<YourUsername>/Library/Android/sdk

Clean and build

Before running your react native project on android make sure you have turn on the Android Emulator by AVD Manager in Android Studio

在此处输入图片说明

If you have not create any emulators then try this link - I have posted full answer on how to make Android Emulator -

React native failed to launch emulator

EDIT :

For adb error you need to install adb drivers on you Mac

Follow these steps

  • First install Homebrew using this command

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

or this command

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After that install adb using homebrew

brew cask install android-platform-tools

Try to re run

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM