Cannot run your app in the native emulator


#1

Hi. I got as far as chapter 1 of the tutorial. :^) https://docs.nativescript.org/angular/tutorial/ng-chapter-1 I got the message: “Cannot run your app in the native emulator.” So I tried to make an artificial device. https://docs.nativescript.org/angular/tooling/android-virtual-devices

I believe the Setup Android Emulators page is completely wrong. It seems to be referring to running on Windows. (environment variables exposed using percent signs, executables end in .exe) But a larger issue: SDK Manager (and AVD Manager) are not available from the command line anymore. Google expects you to install Android Studio.

I found ways around that, and created some devices. But the application won’t really start. I get the message:

Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb server with 'adb kill-server' command. Alternatively, run the Android Virtual Device manager and increase the allocated RAM for the virtual device.

I went so far as to install Android Studio, to get the Google-approved access to the managers. But I still haven’t succeeded.

The next step is to go through some tutorials on Android Studio and solve that as a general problem. And then come back to this problem with greater knowledge.

But I don’t want to do that. Time spent is the enemy of success. Is there a set of instructions that corresponds to the new Android tools?

         Regards, Rick

#2

@RickH

Try to run this command , adb kill-server, and then tns run android and see if it works.
If not try this:
Go to the console and type this command: tns doctor

Make sure you have all the dependencies it requests.

After that type: android
and make sure you have all the android requirements and a emulator set up!


#3

Luis, I have a deadline on another project. I’ll try your suggestions early next week. I wanted to make sure you knew I appreciated your response! – Rick


#4

@RickH
It’s totally ok. I also have another project going on. Let me know if it worked or not!


#5

Hmm. Problem still unknown. I tried the three steps.

Step 1.

Ricks-MacBook-Pro:HelloWorld rickhedin$ adb kill-server

Ricks-MacBook-Pro:HelloWorld rickhedin$ tns run android

Executing before-prepare hook from /Users/rickhedin/work/170625/HelloWorld/hooks/before-prepare/nativescript-dev-typescript.js

Found peer TypeScript 2.2.2

Preparing project…

Project successfully prepared (android)

Searching for devices…

Starting Android emulator with image android2

Waiting for emulator device initialization…

Cannot run your app in the native emulator. Increase the timeout of the operation with the --timeout option or try to restart your adb server with ‘adb kill-server’ command. Alternatively, run the Android Virtual Device manager and increase the allocated RAM for the virtual device.

Step 2.

Ricks-MacBook-Pro:HelloWorld rickhedin$ tns doctor

Verifying CocoaPods. This may take more than a minute, please be patient.

. . .

Updates available

. . .

No issues were detected.

Step 3.

Ricks-MacBook-Pro:HelloWorld rickhedin$ android


The “android” command is deprecated.

For manual SDK, AVD, and project management, please use Android Studio.

For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager


Invalid or unsupported command “”


It just seems as though the instructions don’t correspond to the current version of software.


#6

You can try increasing the timeout option by calling tns run android --emulator --timeout 0

Also try to start the emulator manually and call just tns run android after that.


#7

I have this same problem on OSX and Linux, both with full Android and stock SdkTools installs. Investigating where this thread leaves off above: installing Sdk Tools following the NsativeScript insructions, I found that the android/sdk build script doesn’t actually create any virtual devices. Verify this by running the avdmanager

$  cd $ANDROID_HOME/tools/bin
$  ./avdmanager list

So obviously, I should create some AVDs.

$  ./avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'

Error: Package path is not valid. Valid system image paths are:
null

Other versions of the create command failed similarly. I think this establishes that the instructions on the Advanced Setup pages for Linux and OSX are at least incomplete, and possibly broken if they don’t reflect updates to Android Studio.

If I find a solution using the full Studio, (unsuccessful so far) I’ll post here.


#8

The setup scripts and instructions are being reworked by the team to ensure they work with the latest changes to the default distributions of the Android SDK. Meanwhile you can use Android Studio (tools -> Android -> AVD Manager) to create Emulators from emulator images.


#9

I want to second @Pete.K’s advice. I struggled this weekend getting android up and running on a new mac. Android Studio has the GUIs available to install / update SDKs, add the android support library and the emulators if needed.


#10

I’ve spent a few days trying to get the android emulators working through android studio. There are known bugs right now that the android team is working on. At present my only option is to connect an external device.


#11

You could also use https://www.genymotion.com/