I am new to ionic and I want to run my app on android studio emulator. I did refer the link https://developer.android.com/studio/run/index.html. But I do not seem to understand how to run my ionic app on emulator
问题:
回答1:
First ensure that your Android Studio setup is correctly done. If want to do that from scratch refer these links - link1 and link2. In link2, you can choose your OS as well.
This ionic guide will help you setup ionic project correctly. If you follow this guide entirely, you will see the use of emulate
, platform
, run
, serve
, etc commands of ionic.
Basically what you need to do is first add an android platform to your project:
ionic cordova platform add android
And then emulate your project using:
ionic cordova emulate android
回答2:
First open Android studio and start an emulator wait when its still done (first time needs more time)
test if the emulator is available with `android list devices``
ionic cordova emulate android will publish it on your emulator
回答3:
In the latest Android Studio you need to make at least one project and open the project, and then create AVD (android virtual device) in Tools - Android - AVD Manager, and then in your ionic project
ionic cordova emulate [platform]
回答4:
I was able to run the ionic app in emulator by first launching it from the Android Studio on Windows. Trying to run just by the command timed out. -Start emulator from Studio (Tools | AVD Manager) -On command line, run "ionic cordova emulate android"
回答5:
You can install capacitor which created by the ionic team and i recommend it over cordova
Inside your project do this
ionic integrations enable capacitor
then
npx cap init [appName] [appId]
after that add android or ios folder to your project by this command
npx cap add ios
npx cap add android
then finaly you can run your app by
npx cap open ios
npx cap open android
or this command
ionic capacitor run android
回答6:
You can use this for example :
ionic cordova emulate android -lcs
回答7:
step 1 - Create Virtual Device
- AVDs are managed with the AVD Manager. In the Android Studio welcome screen, click Configure » AVD Manager. The AVD Manager can also be opened inside Android projects in the Tools » AVD Manager menu.
step 2 - set environment From the desktop, right click the Computer icon.->Properties -> Advanced system settings->Environment Variables->User variable ->Path->edit->New and add your emulator path like given below
eg. C:\Users\kunal\AppData\Local\Android\sdk\emulator
then,
ionic cordova platform add android
ionic cordova emulate android
or
ionic cordova run android