How can I prevent copying/pirating native compiled files (.so file) from my Android APK?

105 Views Asked by At

I am using NDK/c++ to do complex calculations in my Android app. After the compilation, .so files are present in the lib folder. I am wondering whether anyone can copy those .so files and use my algorithm in their android app. If possible, how can I prevent that?

1

There are 1 best solutions below

0
On

Yes it's possibile.

You can:

  • check Application's PackageName from your JNI/NDK code to check if it match YOUR specific PackageName
  • generate a MD5/SHA of main "classes.dex" file and verify this hash from your JNI code (this method is the most secure of them but the most long to be done) and trigger a JVM exit if them doesn't match
  • add a cyphed argument on most used JNI method that only your App can encrypt correctly, and then decrypt it from your JNI throwing a JVM exit if the decrypted value is not right