Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sign apk using certificate.pem and key.pk8 in Android Studio by using gradle

how to use below commands in Android Studio? java -jar signapk.jar certificate.pem key.pk8 file.apk file-signed.apk

like image 844
srbhakta Avatar asked May 23 '16 11:05

srbhakta


2 Answers

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:

  1. Download keytool (from the link I gave you)
  2. Generate your keystore file keytool-importkeypair -k ~/.android/key.keystore -p android -pk8 platform.pk8 -cert platform.x509.pem -alias platform
  3. Use it to sign your app, either clicking on 'Build--> Generate Signed Bundle / APK' or using singingConfig in your app's .gradle:
signingConfigs {
    config {
        storeFile file("key.keystore")
        storePassword 'password'
        keyAlias 'alias'
        keyPassword 'password'
        }
}

buildTypes {
    release {
        signingConfig signingConfigs.config
    }
}
like image 125
The Good Giant Avatar answered Dec 17 '22 11:12

The Good Giant


  1. 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)

  2. Sign the APK with the following command: apksigner.bat sign --key .pk8 --cert .x509.pem APKFILE.apk

like image 25
Elad Avatar answered Dec 17 '22 11:12

Elad