Failed to read key AndroidDebugKey from store
Asked Answered
I

6

25

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

Imperceptible answered 26/2, 2019 at 2:7 Comment(1)
Please see: #54815298 Sometimes it is easy to ignore the obvious.Vineyard
V
53

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

Vibrato answered 26/2, 2019 at 6:6 Comment(3)
You have to delete the file when Android Studio is restarting during invalide cache or else it won't work.Dunghill
@Agent0 No that's not the case. It worked for me without invalidate cache restart on Mac. I just deleted the file, and rebuild the project and it workedMercia
I was using Windows, Mac might be different then.Dunghill
A
14

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

Aneto answered 31/7, 2022 at 7:50 Comment(2)
yaa It worked. Thanks HOw did it work? how did the earlier file got invalidate? any idea?Iolenta
This did it for me. I also upgraded android gradle plugin to 7.4.2.Bartolommeo
A
2

Delete and Regenerate Debug Keystore: The debug keystore is automatically generated when you build your Android application for the first time. To delete and regenerate it, follow these steps:

a. Close your Android Studio or any other IDE you're using.

b. Navigate to the directory where your keystore is stored, typically in "C:\Users<your_username>.android".

c. Delete the "debug.keystore" file.

d. Rebuild your project in Android Studio. This will trigger the generation of a new debug keystore.

Clean and Rebuild Project: After regenerating the debug keystore, it's a good practice to clean and rebuild your project in your IDE. This can help ensure that the new keystore is properly used.

Aube answered 26/10, 2023 at 9:33 Comment(0)
M
1

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.
Milson answered 12/9, 2021 at 9:7 Comment(1)
For anyone looking where to find debug.keystore, it's on your /home/<username>/.android/ path.Dunghill
H
1

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

Handset answered 17/4, 2023 at 10:7 Comment(1)
It worked for me, thanks. Howerver, all devices were removed in Android Studio. It didn't matter for me, because I didn't have a lot of ones. But consider that when applying this tip. May be debug.keystore only removing would be more suitable.Coriss
C
0

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.

Concertize answered 20/8, 2023 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.