Scorb
Scorb

Reputation: 1920

Failed to read key AndroidDebugKey from store

All of a sudden, for no apparent reason, I am getting a build error related to my android debug keystore.

It was working fine. I changed some java code, and the minsdk version, then next time I opened it up, it was screaming the following error.

com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store "/home/user/.android/debug.keystore": DerInputStream.getLength(): lengthTag=109, too big.

I have navigated to that directory. The debug key exists, and there was a lock file associated with it, but I deleted that, and the problem persisted. I then delete the keystore, and the problem still persisted with the regenerated one.

When I close android studio and restart, running 'make project' succeeds. But once I try to hit the debugger, it fails. At that point any 'make project' runs also fail.

The build is failing on the task app:packageDebug. When I run task from the command line with gradlew packageDebug, the command succeeds. But from Android Studio it fails.

My Android Studio version is as follows. I am developing on Linux Mint 19.1.

Android Studio 3.3.1 Build #AI-182.5107.16.33.5264788, built on January 28, 2019 JRE: 1.8.0_152-release-1248-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.15.0-45-generic

Upvotes: 27

Views: 40549

Answers (5)

Fenikc
Fenikc

Reputation: 1

I was facing a similar error. I even checked the path of SDK NDK JDK etc. Everything was correct. I was using Unity Editor 2020.1.6f1 Windows. It gave me like 101 errors. The following solution worked for me: 1.) Delete C:\Users\nameofuser\.android 2.) After deleting this folder restart the software you're using. In my case, it was unity.

Upvotes: 0

zhxh
zhxh

Reputation: 159

I had the same problem when I replaced my computer. I solved it with the following steps:

  1. Delete C:\Users\{user}\.android

  2. Restart Android Studio

Upvotes: 1

Binary_Hits00
Binary_Hits00

Reputation: 1491

Delete ".android" folder from c>USER>.android, then build your project again

Upvotes: 15

Zmur
Zmur

Reputation: 334

For me this happened after an OS reinstall. Some project files were not in the VCS and for some reason (most likely because of me) the IDE after importing project from VCS generated some files wrongly.

Luckly I had local copy of the project with all the files. So I:

  • cleaned the project
  • replaced all the newly generated gradle and IDEA files from the 'old' local project
  • restarted AndroidStudio with invalidating caches
  • while it restarts deleted the debug.keystore file (it was locked while IDE was running)
  • then launched the build and it worked OK.

Upvotes: 1

dominicoder
dominicoder

Reputation: 10175

Delete the file itself. Android Studio will generate a new one which hopefully won't have the same issue.

Upvotes: 55

Related Questions