3

I am creating a PhoneGap app using WebStorm (PhoneGap/Cordova App) on a Mac. The problem I have is that the app does not appear in the Android emulator. The emulator appears but the screen with the word "android" does not change to reveal the app:

enter image description here

I have followed the instructions on the Cordova site for Android setup on a Mac:

enter image description here

This is the emulator setup:

enter image description here

I have tried activating and deactivating "Use Host GPU" as per the answers and comments to this question to no use - Android emulator shows nothing except black screen and adb devices shows "device offline"

The app appears and works correctly when I choose "browser" as the Platform in the configuration:

enter image description here

Any ideas what else I need to do?

Edit 1: This is the log information when running in verbose mode as suggested by @Dar

Running command: /Users/username/Documents/Projects/harkme/platforms/browser/cordova/run --emulator

Static file server running @ http://localhost:8000/index.html

CTRL + C to shut down

ANDROID_HOME=/usr/local/Cellar/android-sdk/24.3.4/

JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home > No emulator specified, defaulting to AVD_for_Galaxy_Nexus_by_Google

Waiting for emulator...

emulator: WARNING: VM heap size set below hardware specified minimum of 128MB

emulator: WARNING: Setting VM heap size to 256MB

Hax is enabled

Hax ram_size 0x40000000

HAX is working and emulator runs in fast virt mode.

console on port 5554, ADB on port 5555

Edit 2:

Enabling HAXM as mentioned by @Dar speeds up the emulator greatly to the extent that the "android" page disappears after a few seconds to show the desktop but the app is not installed. However, I found that if I dragged the app from the build folder onto the desktop the app installed. The app file (android-debug.apk) is located in:

platforms/android/build/outputs/apk

This procedure actually (accidentally) improved my workflow as I now just build the app and drag it onto the emulator instead of doing a PhoneGap/Cordova run from WebStorm after making changes to test the app.

I also changed the emulator setup to this:

enter image description here

Edit 3:

Sometimes when launching the emulator the following error appears

Unknown hax vcpu return 1

If it continues to do so, the only way to get round it, at the moment, is to restart the Mac, as suggested here - https://code.google.com/p/android/issues/detail?id=201694

Community
  • 1
  • 1
camden_kid
  • 12,591
  • 11
  • 52
  • 88

1 Answers1

1

Sorry, this is supposed to be some sort of comment but I still don't have enough points to do so.

I cannot go further than the following instructions without knowing what the emulator is logging behind the scenes.

Do update us if you will.

Please try to do the following in your terminal. I have not used WebStorm personally, but the documentation says that the terminal is available to use within the IDE.

This is also assuming you are developing with cordova. If you used ionic or phonegap, please change the command accordingly.

  1. cordova build emulator --verbose

Check whether the application builds successfully or not.

  1. cordova run emulator --verbose

Check whether the emulator successfully defines its properties, builds the application and deploys it to the emulator.


Another problem would be is that it is taking too long to load the emulator. May I suggest that you install HAXM in the Android SDK Manager. HAXM stands for Intel Hardware Accelerated Execution Manager. It will really boost up your emulator performance in terms of speed.


Also, maybe you can try to input some value in the SD Card Size. Maybe 512 MiB would be enough.


If all else fails, delete the emulator and create a new one. Target that emulator using cordova run android --target=emulatorname

Again, if you are able to provide us with log information, please update.

dariru
  • 501
  • 6
  • 16
  • Thanks for your suggestions. The build initially had an error but after some searching I solved that by adding `buildToolsVersion=23.0.3` in the file **project.properties**. Implementing HAXM does indeed speed up the emulator and now the initial "android" screen disappears to reveal the desktop and allows me to interact. However, the app still does not appear nor is it available in **apps** on the emulator. I feel it's nearly there and could be something obvious that I haven't done or set. Using a different emulator didn't solve the problem either. See edit in answer for log information. – camden_kid May 30 '16 at 11:18
  • See also edit 2. Any ideas why the app doesn't install initially? – camden_kid May 30 '16 at 14:38
  • Could you run the emulator with the option `--verbose`? The terminal should output something similar to: `imacxxxxxxxx:xxx xxxxxxx$ cordova run android --verbose Executing "before_run" hook for all plugins. Executing "before_prepare" hook for all plugins. Searching PlatformJson files for differences between project vs. platform installed plugins` It can show why the app doesn't install initially. There was a similar question to yours recently, maybe it can help you further. http://stackoverflow.com/questions/37456371/android-emulator-doesnt-display-app/37475711#37475711 – dariru May 31 '16 at 00:17
  • Related to that question, I don't see `Running command "getprop emu.uuid" on emulator-5554...` when I first run `cordova run --emulator --verbose` but when I run it again after **Ctrl-C** I see `Running command "cat /proc/cpuinfo" on emulator-5554...` and the app loads in the emulator. – camden_kid Jun 03 '16 at 19:33
  • @camden_kid I think it's common to run the emulator again (via `Ctrl+C`) after one go so that the properties are already set by the next run. Glad to hear that the app loads in the emulator already. – dariru Jun 06 '16 at 00:09
  • Thanks for your patience and all your help. If you could summarise your comments as an edit to your answer I will mark it as answered. – camden_kid Jun 06 '16 at 08:15