"ionic serve" works correctly; "ionic emulate android" just displays android emulator home screen

Hi forum, I am a first time user of ionic so please bear with me.

I am following the basic Ionic Book tutorial. Everything is going well until I got to Chapter 4 where I need to test my app.

Using the command “$ ionic serve” loads up my “todo” app in Google Chrome, which is what I expected. However, using the command “$ionic emulate android” loads up the android emulator as expected, however fails to load the app itself. The android emulator home screen appears to be working perfectly (button clicks, menu function, etc.) however I was expecting my “todo” app to open (and it doesn’t).

Is there anything I can do to check why it is not opening? Any settings I need to check? Anything I possibly haven’t configured?

Here are some of my system info details. Please let me know if I am missing anything:
Cordova Version: 6.2.0
Ionic Framework Version: 1.3.1
Ionic CLI Version: 1.7.15
Ionic App Lib Version: 0.7.2
OS: Windows 7 SP1
Node Version: v5.11.1
Android Studio Version: 2.1.1
AVD: Nexus 5X (Marshmallow / API 23 / Android 6.0 x86)

Have you tried ionic run android ? Are there any errors in the console?
I would always recommend testing on a real device anyways. Either through ionic run or using the great ionic view app which is quite easy to set up.

1 Like

I’ve tried ionic run android and the only difference between that and ionic emulate android is an additional line in the console stating that no device was detected, so the app will be pushed to the emulator (sorry i’m not at my dev machine right now so can’t provide you with the exact text).

No other errors were visible using the console.

I was hoping to use the emulator to begin with, then eventually begin to test on a real device. Thanks for recommending the use of ionic view app, I’ve successfully managed to get that to work.

I would still like to resolve this ionic emulate android issue if there are any other suggestions?

It would be helpful if you could provide the whole console output.
Does the app build successfully? Have you checked whether the app is installed on the emulator?

Maybe try running adb logcat from a different cmd while you run the emulator. This should show you problems with the emulator.

This is what the console displays when I run ionic emulate android:

image

This is what the console displays when I run ionic run android:

image

And this is what is displayed on my emulator (i.e. just the home screen):

It is my understanding (based on online instructions and videos) that the emulator should open the app content immediately upon startup and should not just display the home screen. The app is not “installed” on the emulator because I don’t believe I have got that far yet (in regards to packaging an app that becomes installed / has it’s own icon.

I ran adb logcat (in a separate cmd prompt) prior to running the ionic emulate android command and then stopped it after the emulator had loaded. The output is approx 23,000 lines long. If you’d like to see it then let me know the best way to share it with you.

Looks like your app doesnt even build. Weird that it doesn’t give you any errors. Are your path variables setup correctly? Maybe go through this and check if everything is setup properly: http://www.tiagoporto.com/blog/environment-setting-tutorial-ionic-android-on-windows/
Is ionic build android for you? Are there any .apk s in your build folder?

OK, my problem is RESOLVED (I believe). What I ended up doing was running the emulator via a cmd prompt (i.e. ionic emulate android) so that it opened the emulator on the home screen. I then opened another cmd prompt and ran the ionic emulate android command again and this resulted in what looks like an installation and launch of the application onto the open emulator (see cmd prompt screenshot below). It is now behaving as expected.

Thanks so much for your help.

7 Likes

You are a genius!! Thank you!! I wonder what is the problem there and how come is not working as smoothly as ionic emulate ios in my case. Is it intentional or bug?

1 Like

I got the same problem and your answer saved the day. Btw, what does actually cause the problem?