Error ionic cordova run android A failure occurred while executing com.android.build.gradle.tasks

Hello friends. I haven’t found a solution to this problem for several days. I can’t run the command
ionic cordova run android.
It throws me the following error.

Execution failed for task ':app:packageDebug'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "/home/user/.android/debug.keystore": Invalid keystore format

The ionic cordova build --release command works perfect.
The command ionic cordova build --packageType=apk, gives me the same error.
I do not understand why!

IONIC INFO =>

Ionic:

   ionic (Ionic CLI)  : 4.11.0
   Ionic Framework    : ionic-angular 3.9.4
   @ionic/app-scripts : 3.2.4

Cordova:

   cordova (Cordova CLI) : 11.0.0
   Cordova Platforms     : android 10.1.2
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 26 other plugins)

System:

   Android SDK Tools : 26.1.1 (/home/user/Android/Sdk)
   NodeJS            : v14.19.1 (/home/user/.nvm/versions/node/v14.19.1/bin/node)
   npm               : 6.14.16
   OS                : Linux 5.13

cordova requirements

android-targetSdkVersion should be greater than or equal to 30.

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-30,android-29,android-27
Gradle: installed /opt/gradle/gradle-7.4.2/bin/gradle

Is it a version problem?
Is it a SDK version problem?
Has anyone encountered this problem?

Thanks to you!!

Hi
Did you find a solution to the problem? Currently facing the same issue

1 Like

facing same issue on windows 10

I have a solution for it, remove android studio, restart and then remove .android folder from Users folder, i.e C:\Users\USERNAME .android.

then remove the platform from cordova app, i.e using ionic cordova platform rm android.

then execute: ionic cordova run android.

it will work

forgiveness for slow to respond. I have a lot of work.
I solved the problem by removing all the CORDOVA plugins and then installing them again, but it really cost me a lot of work to solve that, since the application had more than 25 plugins, but that was the solution I found. I don’t know if it was the best, but it was what I was able to solve the problem with, thanks.

I fixed the issue by deleting the following files:

C:\Users\your_user.android\debug.keystore
C:\Users\your_user.android\debug.keystore.lock

After that, the next build was a success. Also, after the build, these files were created again.

I do not now the real cause of the problem, though.

Hope it can help somebody out.

Hello @Alexander0821! I had to postpone that task, for later, and that happened today! and your solution has helped me in an incredible way! I remembered that I had asked the question and found this answer has solved a past headache for me, therefore thank you very much!

1 Like

the answer for Linux is below, thanks for participating.

deleting the debug.keystore then running the build command worked for me

Sorry for my late answer, but this is the correct answer, I don’t know if the solution to the problem but this has allowed me to continue with my work. I hope someone finds it useful and thank you very much.