Verify Android apk has not been repackaged?

I ended up using Dexguard (paid obfuscator for Android). It offers a module that preforms apk verification. It is simple to implement and offers better than average protection.

Here's the code to do the check:

dexguard.util.TamperDetection.checkApk(context)

The main issue is where to store the checksum of the apk to verify against given that it could to be replaced. The dexguard way is to check it locally but using other features like class/string encryption and api hiding obscure this call.


Here are some of the articles that could help you out.

Retrieving APK signature during runtime.
Self checking an APK signature.
How to check APK signature.