10

I've been trying to generate an .apk (debug or release) and I've been getting this error:

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

I already tried creating a new key (with key and alias with the same name) on Android Studio, I deleted the .android/debug.keystore and run the following commands (from here):

keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -deststoretype pkcs12

and

 keytool -importkeystore -srckeystore new.keystore -srcstoretype pkcs12 -destkeystore final.keystore -deststoretype jks

What else can I do to run my app?

OS: Ubuntu 18.04

Android Studio 3.3.1

Community
  • 1
  • 1
yasin
  • 1,297
  • 3
  • 17
  • 36
  • You mention that you created the key using AS then deleted the keystore and recreated it using the command line, is that correct ? why not just create everything using AS tool, it's pretty straightforward? – 113408 Feb 14 '19 at 20:36
  • @113408 I created the key on AS and got this error. Delete it and created again using command line, got the same error. – yasin Feb 15 '19 at 10:49

2 Answers2

12

Try upgrading gradle from in the gradle-wrapper.properites file from 4.10.1 to 4.10.2. I had the same problem, and that fixed it for me.

mtthws
  • 144
  • 1
  • 2
  • 3
    After trying everything I could find, nothing worked. Then I did two things that finally got me up any running. 1) Regenerated the keystore using this url: https://coderwall.com/p/r09hoq/android-generate-release-debug-keystores I also used the suggested step to convert the jks to pkcs12, this step was provided when you run the keytool command. 2) Then I created a new React Native app folder by doing react-native init myNewAppName This time when I ran the react-native run-android everything build fine. – Joey Garcia Apr 07 '19 at 14:38
  • Thank you so much. It saved me a lot of time and effort. – PunK _l_ RuLz Mar 02 '20 at 13:02
  • Wow, thanks! There was a Gradle upgrade message in AS and I accepted it and the signing worked again. – Lucy Jul 21 '21 at 04:22
12

Probably not the exact answer but the below steps solved my problem. Because I was already using gradle 4.10.2.

Steps:

  1. Delete .gradle folder from android folder.

  2. Run react-native run-android.

The above steps fixed the problem.

MrPromethee
  • 721
  • 9
  • 18