LoginSignup
44
32

More than 3 years have passed since last update.

ExpoでAndroidエミュレータが起動しない場合

Last updated at Posted at 2020-03-16

概要

React Nativeを触るためにExpoをインストールしてIOS/Androidエミュレータを試しに起動したところ、Androidエミュレータで以下のエラーが発生してそれを解決した備忘録。

Couldn't start project on Android: Error running adb: No Android connected device found, and no emulators could be started automatically.

Please connect a device or create an emulator (https://docs.expo.io/versions/latest/workflow/android-studio-emulator).

Then follow the instructions here to enable USB debugging:

https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select "Use custom Android SDK tools", and point it at your Android SDK directory.

エミュレータを作ろう

  1. Android Studioを立ち上げて右下のConfigureをクリック
  2. プルダウンのうち「AVD Manager」をクリック
  3. Android Virtual Device Managerが立ち上がるので、下の方にある「+ Create Vitural Device...」をクリック
  4. デバイスの選択になるので、特にこだわりがなければデフォルトのPixel 2のまま「Next」をクリック
  5. システムイメージの選択になるので、特になんでも良いがTargetがAndroid 10.0を選択して「Next」をクリック
  6. そのまま「Finish」をクリック
  7. エミュレータの完成

Android Studio's toolsのセットアップ

  1. Android Studioの左上のメニューから「Preference」をクリック

  2. 左のツリーから、 Appearance & Behavior → System Settings → Android SDK を選択

  3. 上の方にある「Android SDK Location」をコピーする

  4. ターミナルを開く

  5. vimなどで~/.bash_profile、zshなら~/.zshrcを開き、下記のようにexportをつけてペーストする(usernameはそれぞれのPCの名前)

   export ANDROID_SDK=/Users/username/Library/Android/sdk

vim閉じずにそのまま次へ

  1. platform-toolsを追加する
   export PATH=/Users/username/Library/Android/sdk/platform-tools:$PATH
  1. ターミナルを再起動

  2. adbコマンドが使えるか確認する

   $ adb version

AndroidエミュレータにExpoをインストール

  1. Android Studioを立ち上げて右下のConfigureをクリック

  2. プルダウンのうち「AVD Manager」をクリック

  3. 先ほど作成したエミュレータを選択し、右のActionsの中の▶︎をクリック

  4. エミュレータが起動するまで待つ

  5. 起動を確認したらターミナルへ移動

  6. expoのプロジェクトがあるディレクトリへ移動しexpoを起動させる

   $ cd ~~~~~  ディレクトリの移動
   $ expo start
  1. ブラウザが自動的に立ち上がるので、左の「Run on Android device/emulator」をクリック

  2. エミュレータにexpoがインストールされる

  3. 無事Androidエミュレータ上でexpoが動く

次回以降

IOS simulatorと違って、Androidでチェックしたい時は毎回Android Studioからエミュレータを起動して、expoからRunしないとダメなよう

44
32
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
32