Skip to main content

Attempting to run a preview, and I'm seeing the following error in Android Studio

DerInputStream.getLength(): lengthTag=107, too big.

 

After a some searching, options that I came across was to try converting the Keystore to pk12.  But to no avail.  

Looking at a more detailed error response

Execution failed for task ':app:packageRelease'.
> A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable
   > com.android.ide.common.signing.KeytoolException: Failed to read key upload from store "/Users/{user}/Apps/{location}/private_key.pepk": DerInputStream.getLength(): lengthTag=107, too big.

So the issue is specifically with the private_key.pepk file.

This happens because the private key generation command uses java - the same java version which caused the exception in the first place.

You should use a different java 8 version, in which the exception won't occur (like 1.8.0_112).  It won't work with java 7 and earlier because the pepk tool is build with java 8.

 

Java version check

To check the current version of Java being used, run the following command

java --version

Response will be similar to

openjdk 11.0.20.1 2023-08-24
OpenJDK Runtime Environment Homebrew (build 11.0.20.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.20.1+0, mixed mode)

The version the key was built on was

openjdk 11.0.17 2022-10-10

So the issue is not with the key used to generate pepk key.