Search code examples
androidcordovaionic-frameworkkeytool

Sign a debug APK file while using cordova run command line


I would like to test and debug a signed version of a APK file, using Apache Cordova command line. When we run either cordova build android or cordova run android --device a APK file is created at:

<project_dir>/platforms/android/build/outputs/apk/debug/android-debug.apk

Can we sign this debug file before sending it to the device while running cordova run android --device?

Or is this android-debug.apk already signed with a SHA1, and if so how to get that signature?


Solution

  • It's already signed with the certificate of name androiddebugkey in the ~/.android/debug.keystore keystore.

    To get the signature:

    keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore > debug.crt
    openssl sha1 -binary debug.crt > debug.sha
    openssl base64 -in debug.sha > debug.txt