5

I'm trying to make my environment work with Cordova and Android emulator with no success. I have installed the Android Studio and I can successfully start the Android Emulator.

I have created a cordova application with the command below:

cordova create myApp

I added support for the Android platform:

cordova plataform add android

I had the following output:

Using cordova-fetch for cordova-android@~6.2.2
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android@6.2.3
Installing "cordova-plugin-whitelist" for android

   This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

--save flag or autosave detected
Saving android@~6.2.3 into config.xml file ...

Then I try to run the application:

cordova run android

The emulator starts, after a while, that I have the error below in the command prompt:

No target specified and no devices found, deploying to emulator
No emulator specified, defaulting to Nexus_5X_API_24
Waiting for emulator to start...
Error: Failed to execute shell command "getprop,dev.bootcomplete"" on device: 
Error: C:\Users\username\AppData\Local\Android\sdk\platform-tools\adb.exe: Command failed with exit code 3221226356

Does anyone knows how to fix this error?

Some others environment info:

C:\>node -v
v7.4.0

C:\>cordova -v
7.0.1

C:\>java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Edit 1

I have done those steps:

  1. Uninstalled "Android SDK Tools"
  2. Uninstalled "Android Studio"
  3. Deleted files from "C:\Users\USER\AppData\Local\Android\sdk" and "C:\Program Files\Android\Android Studio" files (Because some maybe in use during the uninstallation)
  4. Installed Android Studio
  5. Updated Android Studio

When I execute the command below, I have more information about the error:

cordova run android --verbose

With this output:

Command finished with error code 3221226356: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe -s,emulator-5584,shell,cat,/proc/cpuinfo Error: Failed to execute shell command "cat,/proc/cpuinfo"" on device: Error: C:\Users\USER\AppData\Local\Android\sdk\platform-tools\adb.exe:Command failed with exit code 3221226356

When I execute the command below, the adb shows the emulator cpu info, after that, the process stops and the windows ask to break or debug

adb -s emulator-5584 shell cat /proc/cpuinfo
mqueirozcorreia
  • 905
  • 14
  • 33
  • I had an advice to install Android SDK in a smaller path. So I changed the default installation from: C:\Users\USER\AppData\Local\Android\sdk To: C:\Android\sdk The Android Studio was installed in : C:\Android\Android Studio The Gradle in: C:\Gradle\gradle-4.0.1\bin I had the same error. – mqueirozcorreia Jul 12 '17 at 14:10
  • I found this answer to work: https://stackoverflow.com/a/56474669/1766526 It only requires downgrading 3 adb files, not the whole SDK platform. – ExactaBox Jun 11 '19 at 00:07

3 Answers3

6

Downgrade your SDK platform-tools to rev25.0.1.

If you dev in windows, you can download it in https://dl-ssl.google.com/android/repository/platform-tools_r25.0.1-windows.zip

delete or rename your old platform-tools folder, and extract the downloaded file to it.

Works for me!

  • Unfortunately, it did not work. Were you having the same error before applying your solution? – mqueirozcorreia Aug 04 '17 at 09:50
  • I also had problems with adb Version 29 and downgraded to 28 (https://dl.google.com/android/repository/platform-tools_r28.0.2-windows.zip). If I executed in a cmd.exe window, adb -s myDeviceNumber shell cat /proc/cpuinfo , seemed Ok but in reality it was crashing after executing correctly leaving a crash file AppCrash_adb.exe_xxxxx in C:\ProgramData\Microsoft\Windows\WER\ReportArchive and after that typing, echo Exit Code is %errorlevel%, echoed Exit Code is -1073740940 which is equivalent to 3221226356 (uint instead of int). – xyq.384.b Jun 10 '19 at 20:50
4

I encountered the same issue with an emulator of Nexus5 & Oreo/Nougat.

I changed my emulator to Galaxy Nexus & Lollipop and it worked fine without any modification in the Cordova directories.

It does not seem to be the right solution, but some lower combinations might be available for avoiding this issue.

The command line is:

 $ cordova emulate android

The following is the success log:

No emulator specified, defaulting to Galaxy_Nexus_API_22
Waiting for emulator to start...
emulator: Requested console port 5584: Inferring adb port 5585.
emulator: WARNING: encryption is off
path /home/ximia/.android/avd/Galaxy_Nexus_API_22.avd/system.img.qcow2
Waiting for emulator to boot (this may take a while)...BOOT COMPLETE

ADyson
  • 57,178
  • 14
  • 51
  • 63
ximia
  • 41
  • 2
  • The same error: `No emulator specified, defaulting to Galaxy_Nexus_API_22 ... Error: Failed to execute shell command "getprop,dev.bootcomplete"" on device: Error: C:\Android\sdk\platform-tools\adb.exe: Command failed with exit code 3221226356` – mqueirozcorreia Nov 14 '17 at 13:29
2

Edit your virtual device (ADV) and go into advanced settings and uncheck Multi-Core CPU.

Work fine to me.

Klaid Dias
  • 408
  • 4
  • 7
  • Unfortunately, it did not work. Why do you think this is the problem? Because I can try to track the problem with your idea. – mqueirozcorreia Jun 09 '17 at 17:45
  • This worked for me. I like this solution (if it works for you) better than downgrading tools versions as staying on backdated tools will eventually cause you problems. – Brian Bauman Mar 25 '19 at 16:20