[ERROR] An error occurred while running ionic cordova run android :


ionic cordova build android

But doing

ionic cordova run android

Gives follow error:



Total time: 1.513 secs
Built the following apk(s): 

No target specified, deploying to device '99ffee11'.

Skipping build...
Built the following apk(s): 

Using apk: /Users/myusername/Documents/MobileApps/TestProjekt/testapp/platforms/android/build/outputs/apk/android-debug.apk

Package name: com.ionicframework.xxxxxxmyproject
Error: Failed to install apk to device: [  0%] /data/local/tmp/android-debug.apk
[  0%] /data/local/tmp/android-debug.apk
[  1%] /data/local/tmp/android-debug.apk
[  1%] /data/local/tmp/android-debug.apk
[  2%] /data/local/tmp/android-debug.apk
... and so on until I get to 85-86 %
[ 85%] /data/local/tmp/android-debug.apk
[ 86%] /data/local/tmp/android-debug.apk
[ 86%] /data/local/tmp/android-deb
[ERROR] An error occurred while running cordova run android (exit code 1).

Now doing

ionic cordova build android --verbose

Only gives:

[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: '/Users/myusername/Documents/MobileApps/TestProjekt/testapp', local: false, 
        binPath: '/Users/myusername/.nvm/versions/node/v6.7.0/lib/node_modules/ionic/bin/ionic', libPath: 
        '/Users/myusername/.nvm/versions/node/v6.7.0/lib/node_modules/ionic/dist/index.js' }
[INFO] Running app-scripts build: --platform android --target cordova
[14:55:40]  build dev started ... 
[14:55:40]  clean started ... 
[14:55:40]  clean finished in 2 ms 
[14:55:40]  copy started ... 
[14:55:40]  deeplinks started ... 
[14:55:41]  deeplinks finished in 200 ms 
[14:55:41]  transpile started ... 
[14:55:44]  transpile finished in 3.28 s 
[14:55:44]  preprocess started ... 
[14:55:44]  preprocess finished in 1 ms 
[14:55:44]  webpack started ... 
[14:55:44]  copy finished in 3.64 s 
[14:55:55]  webpack finished in 10.98 s 
[14:55:55]  sass started ... 
[14:55:57]  sass finished in 1.70 s 
[14:55:57]  postprocess started ... 
[14:55:57]  postprocess finished in 181 ms 
[14:55:57]  lint started ... 
[14:55:57]  build dev finished in 16.48 s 
> cordova build android
â ™ Running command [14:55:59]  lint finished in 2.21 s 
âś” Running command - done!
Subproject Path: CordovaLib
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
	at build_167y1yhg7ha0lyifkohm7bxp2.run(/Users/myusername/Documents/MobileApps/TestProjekt/testapp/platforms/android/build.gradle:138)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:preReleaseBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE

Without any particular error.
Even if i try to remove platform install it again
it gives the same result as succeed

The only clue I got from this might be with the gradle 4.0 or 5.0
But I have no idea what really to do.

Here’s my setups:

cli packages: (/Users/myusername/.nvm/versions/node/v6.7.0/lib/node_modules)

    @ionic/cli-utils  : 1.13.1
    ionic (Ionic CLI) : 3.13.2

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

    @ionic/app-scripts : 3.0.1
    Cordova Platforms  : android 6.2.3 ios 4.1.0
    Ionic Framework    : ionic-angular 3.8.0


    Android SDK Tools : 25.2.5
    ios-deploy        : 1.9.1 
    Node              : v6.7.0
    npm               : 3.10.8 
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b 


Can you create a new project and build that?
Is this a physical or virtual device?
Can you run it to a virtual device (via android studio)?


Do you have an example project that can replicate this error?



It works to create a new blank ionic project.
So far so good.

That mean two things, there is not necessarily a bug in the “overall” system in ionic, android or cordova.
But in the other project more likely a small differences between versions in different packets or resources somewhere that cause this conflict. Or it might have to do with config.xml settings vs what android package is setup too.
It was giving a hint that something in build.gradle wasn’t happy about this. So I will check that out.
But that is my guess so far.

But I will check that and come back soon.
So people could get help on this one if they land in a similar situations.

Stay tune.


And there you go.
The problem seems only laying in config.xml file.

Of some reason (based on my settings above)
I couldn’t use:

<preference name="android-minSdkVersion" value="25" />

It didn’t like that I use min version 25 here. But surprisingly I set it to be much lower
than to be the expected value which would be 26 here.

The blank ionic project version was using the android-minSdkVersion 16. And that really work for me!

Expanded explanations

Ok I have a very good explanations or hint for this.
This was totally my wrong. But why it didn’t work is obvious in this case.
If I get look into the settings in my android phone I still use 5.0.1
According to
That mean I can’t upload an higher version than API level of 21
which was the number I could use in my case in android-minSdkVersion or better to put that in the android-targetVersion rather than minSdkVersion.

Another explanations why that should be used in targetVersion rather than minSdkVersion could be readed here:


Sometimes this problem could cause by missing to update the android sdk. If you use a version of API that isn’t been downloaded yet in android sdk manager.

So there you have it.