Android Studio Build of App fails claiming Keystore was tampered with

I have had this problem in Android Studio 3.3 and Gradle Build Tools 28.0.3

I did not forget the password and the keystore was not tampered with. What had happened was that i had changed to a very old branch in my Git repo. And the project had a different structure. Though there was no difference in the keystore, the project was very different.

This caused me build errors due to the build files being cached. After i invalidated and restarted and rebuilt the project this is when the problem started. I had no idea at first that it was that, since the error is quite explicit.

But what pointed me in the right direction was that i changed back to the more advanced branch and then had the same build problems as before, solved them as above, then still had the password issue with the key. I then created a new key in the same keystore with a different name. After i went back to the older branch and repeated the clean up process , i got a new error stating that the key that i had created in the latest branch, could not be found. So that made me realise that Gradle could be the culprit.

I deleted the gradle folder and the build folder and also invalidated cache and restarted Android Studio. Then it just worked.

Hope it helps someone


I edited my build types under Project Structure and removed the signing config, to see if that was the problem. That worked so I could build the APK again. Now I have a new problem, where I can't seem to get the apk to install on my phone. But that sounds like a separate problem. I'll post a new question.

BTW, thanks to Kashan Danish for the suggestion.