Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error running PEPK app signing tool at command line (java -jar pepk.jar)

I'm getting the output:

Error: null

from the command (executed at the command line):

java -jar pepk.jar --keystore=my.keystore --alias=x --output=my.output --encryptionkey=1243

Anyone any idea why or how to resolve it?

The "my.keystore" file exists and is a keystore. The alias is correct and the "my.output" file doesn't exist. I have changed the encryptionkey value in the example above but no matter what values I use I always get the same output.

I've tried double quoting the keystore and output values and providing (with quotes) full paths to the keystore file and the output file. Still the same error output. The jar is being executed because I get the usage help displayed if something is missing. I've also tried running the command in different directories and ensured that the permissions in the output directory is correct.

I'm using java version:

java version "9" Java(TM) SE Runtime Environment (build 9+181) Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

on Windows 10. (I've tried paths with both / and ). The pepk.jar was downloaded on the same day this question was posted from the App Signing page on the Play Store for my app.

Update, with new version downloaded as of 17/Sep/2018:

After downloading the new version of pepk.jar as suggested by Pierre the output is now:

Error: Unable to export or encrypt the private key
java.lang.NullPointerException
at com.google.wireless.android.vending.developer.signing.tools.extern.export.KeystoreHelper.loadKeystore(KeystoreHelper.java:45)
at com.google.wireless.android.vending.developer.signing.tools.extern.export.KeystoreHelper.getPrivateKey(KeystoreHelper.java:38)
at com.google.wireless.android.vending.developer.signing.tools.extern.export.ExportEncryptedPrivateKeyTool.run(ExportEncryptedPrivateKeyTool.java:114)
at com.google.wireless.android.vending.developer.signing.tools.extern.export.ExportEncryptedPrivateKeyTool.main(ExportEncryptedPrivateKeyTool.java:79)

I've double checked the keystore and it contains a private key, via the use of keytool -list -v -keystore.

like image 832
Gary Bentley Avatar asked Sep 11 '18 06:09

Gary Bentley


4 Answers

You have atleast Java Version 8(JDK 1.8) to run the syntax:

java -jar PATH_TO_PEPK --keystore=PATH_TO_KEYSTORE --alias=ALIAS_YOU_USE_TO_SIGN_APK --output=PATH_TO_OUTPUT_FILE --encryptionkey=GOOGLE_ENCRYPTION_KEY

Legend:

  • PATH_TO_PEPK = Path to the pepk.jar you downloaded, could be something like C:\Users\YourName\Downloads\pepk.jar for Windows users.
  • PATH_TO_KEYSTORE = Path to keystore which you use to sign your release APK. Could be a file of type *.keystore or *.jks or without extension. Something like C:\Android\mykeystore or C:\Android\mykeystore.keystore.
  • ALIAS_YOU_USE_TO_SIGN_APK = The name of the alias you use to sign the release APK.
  • PATH_TO_OUTPUT_FILE = The path of the output file with .pem extension, something like C:\Android\private_key.pem
  • GOOGLE_ENCRYPTION_KEY = This encryption key should be always the same. You can find it in the App Signing page, copy and paste it. Should be in this form: eb10fe8f7c7c9df715022017b00c6471f8ba8170b13049a11e6c09ffe3056a104a3bbe4ac5a955f4ba4fe93fc8cef27558a3eb9d2a529a2092761fb833b656cd48b9de6a

Example:

java -jar "C:\Users\YourName\Downloads\pepk.jar"
--keystore="C:\Android\mykeystore" --alias=myalias --output="C:\Android\private_key.pem" --encryptionkey=eb10fe8f7c7c9df715022017b00c6471f8ba8170b13049a11e6c09ffe3056a104a3bbe4ac5a955f4ba4fe93fc8cef27558a3eb9d2a529a2092761fb833b656cd48b9de6a

After entering the command in the terminal, you will need to provide the following:

  1. The keystore password
  2. The alias password

If everything has gone OK, you now will have a file in PATH_TO_OUTPUT_FILE folder called private_key.pem.

More resources:

  • How to enable google play app signup official documentation
  • Step-by-step implementation blog
like image 183
droidBomb Avatar answered Nov 19 '22 20:11

droidBomb


I finally got around this problem by using the standard Windows (10) command prompt, i.e. "cmd". It seems that the System.getConsole is returning a non null value for cmd.

I haven't been able to find any information on what is happening with mingw64 (the command prompt I generally use on Windows) and why the System.getConsole isn't being set up.

like image 24
Gary Bentley Avatar answered Nov 19 '22 20:11

Gary Bentley


If you are using gitbash, you have to pre-fix the command with

winpty

as the PEPK command requires console input. (or run is via a standard windows CMD prompt)

like image 7
Chris Leathley Avatar answered Nov 19 '22 20:11

Chris Leathley


I really appreciate the response given by @droidBomb in previous Answer.

The solution for xamarin Android is slight different. REQUIRED FLAGS

--keystore Path to the keystore containing the private key to export(Eg:C:\Users\YourName\Downloads\abc.keystore)"

--alias Alias of the private key in the keystore(Eg:upload)

--encryptionkey Public key to encrypt the private key with. This will be be the hex encoded bytes of the public key. The public key is a 4-byte identity followed by a 64-byte P256 point.(Eg: eb10fe8f7c7c9df715022017b00c6471f8ba8170b13049a11e6c09ffe3056a104a3bbe4ac5a955f4ba4fe93fc8cef27558a3eb9d2a529a2092761fb833b656cd48b9de6a)

--output File in which to output the encrypted private key.(Eg:C:\Users\YourName\Downloads\private_key.pem)

  1. Open the Command Prompt
  2. Download the pepk file from Google Console of Your application.
  3. Prepare the command like following
  4. java -jar "C:\Users\YourName\Downloads\pepk.jar" --keystore="C:\Users\YourName\Downloads\upload.keystore" --alias="upload" --encryptionkey=eb10fe8f7c7c9df715022017b00c6471f8ba8170b13049a11e6c09ffe3056a104a3bbe4ac5a955f4ba4fe93fc8cef27558a3eb9d2a529a2092761fb833b656cd48b9de6a --output="C:\Users\YourName\Downloads\private_key.pem"

The respective pem file will be generated at output path

like image 5
Nawin Avatar answered Nov 19 '22 20:11

Nawin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!