Cordoba error running on Android emulator: "android: command failed with exit code 2"

I am trying to run my cordova project in an Android emulator:

cordova emulate android 

The build is successful, but the emulator does not start, and I get an error message:

 Error: android: Command failed with exit code 2 

I get the same when running cordova requirements :

 Requirements check results for android: Java JDK: installed 1.8.0 Android SDK: installed true Android target: not installed android: Command failed with exit code 2 Gradle: installed /opt/android-studio/gradle/gradle-3.2/bin/gradle Error: Some of requirements check failed 

I updated the Android SDK Tools to 26.0.1 and the android command no longer works for me. So I installed cordova-android@6.2.1 , since the page release says and uses it in my project:

 $ cordova platform ls Installed platforms: android 6.2.1 Available platforms: amazon-fireos ~3.6.3 (deprecated) blackberry10 ~3.8.0 browser ~4.1.0 firefoxos ~3.6.3 ubuntu ~4.3.4 webos ~3.7.0 

But the error still occurs. Anyone have any idea why this is happening?

+7
android cordova
source share
3 answers

I think the new version of the Android SDK is not compatible with cordova emulation, so I change this:

 return superspawn.spawn('android', ['list', 'avds']) 

:

 return superspawn.spawn('android', ['list', 'avd']) 

inside

 platforms/android/cordova/lib/emulator.js 

and bug fixed. This is because the "avdes list avds" command has been changed to the "android avd list" inside the new SDK. Thanx to Douglas Neves

If after that you catch one more error:

 Failed to install ... Failure [INSTALL_FAILED_VERSION_DOWNGRADE] 

You will need to change this:

 var command = 'adb -s ' + target + ' install -r "' + apk + '"'; 

:

 var command = 'adb uninstall "' + pkgName + '"; adb -s ' + target + ' install -r "' + apk + '"'; 

in the same file. This code will remove the application before installing it, so the version issue will disappear.

+21
source share

you should update the latest platform:

 cordova platform remove android cordova platform update android@latest 
+5
source share

You must save the entire workspace for ion input in folder C with the folder.

Runtime error for task: error mergeDebugResources will be resolved.

-one
source share

All Articles