I thought about this, and it seems that if you really want to protect your application from hackers, there is only one way to do this. You can implement all kinds of fancy insurance methods for your application, which is licensed and paid, as described in a Google article, but all that is required is a good hacker to decompile your application and find where the code is located, then comment on it or change the function to always return true.
Instead, run some of your application, which is required for use in jni / ndk, and check for validation in this code. It doesn't have to be extremely complex code, but you can't just put something like a function (like checkValidity), as the user can easily comment on the java call that calls into ndk. Instead, you should make some call to your ndk in order to actually do something that is not trivial to run your application, that the user cannot simply comment on or off with a specific function that does the same. From the ndk code, check the integrity / licensing of your application, and if it fails to destroy the application or something else you need to do.
To get around this, the hacker will need to re-implement the ndk code or reverse engineer it. Which should be much more complicated and not worth it.
This is obviously not a simple solution and still does not guarantee that your application will never be hacked, but it is much harder to break than other methods.
Matt wolfe
source share