Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get APK signing signature?

Is there a way to retrieve the signature of the key used to sign an APK? I signed my APK with my key from my keystore. How can I retrieve it programmatically?

like image 809
Waypoint Avatar asked Apr 07 '11 09:04

Waypoint


People also ask

Does APK need to be signed?

All applications must be signed. The system will not install an application on an emulator or a device if it is not signed. To test and debug your application, the build tools sign your application with a special debug key that is created by the Android SDK build tools.


1 Answers

You can access the APK's signing signature like this using the PackageManager class http://developer.android.com/reference/android/content/pm/PackageManager.html

Signature[] sigs = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures; for (Signature sig : sigs) {     Trace.i("MyApp", "Signature hashcode : " + sig.hashCode()); } 

I've used this to compare with the hashcode for my debug key, as a way to identify whether the APK is a debug APK or a release APK.

like image 55
Ollie C Avatar answered Oct 27 '22 16:10

Ollie C