Reputation: 75
how to use below commands in Android Studio? java -jar signapk.jar certificate.pem key.pk8 file.apk file-signed.apk
Upvotes: 6
Views: 12045
Reputation: 107
Try adding the following to a .cmd file
set /P apk="What is the path of the APK?"
"C:\Users\<your user name>\AppData\Local\Android\Sdk\build-tools\<any folder>\apksigner.bat" sign --key "C:\Users\<your user name>\Documents\platform.pk8" --cert "C:\Users\<your user name>\Documents\platform.x509.pem" %apk%
Upvotes: 0
Reputation: 1655
Copy APK and Key Files to the following folder: C:\Users%USERNAME%\AppData\Local\Android\Sdk\build-tools* (Any of the subfolders will do; for example: 27.0.3)
Sign the APK with the following command: apksigner.bat sign --key .pk8 --cert .x509.pem APKFILE.apk
Upvotes: 1
Reputation: 1780
My reply comes probably too late for the question itself, but could be useful to someone else.
In order to sign an apk with Android studio you need to provide a .keystore file. Now, following this tutorial I found this tool that allows you to create a keystore file starting from your .pk8 and .pem files. All you have to do is:
keytool-importkeypair -k ~/.android/key.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform
signingConfigs {
config {
storeFile file("key.keystore")
storePassword 'password'
keyAlias 'alias'
keyPassword 'password'
}
}
buildTypes {
release {
signingConfig signingConfigs.config
}
}
Upvotes: 14
Reputation: 74
java -jar signapk.jar <path_to_certificate>/certificate.pem <path_to_key>/key.pk8 <path_to_your_apk>/yourapp-unsigned.apk yourapp-signed.apk
Upvotes: 1