0

I want to build a secure release apk, It's mean that anyone can not mod or Tampering (hack)

Manohar
  • 22,116
  • 9
  • 108
  • 144

2 Answers2

2

There's no way to protect your app 100% from being modified, but to make it harder for hackers to understand and modify your code, change minifyEnabled to true in your build.gradle file. You can read more about shrinking and optimizing your app here. https://developer.android.com/studio/build/shrink-code

android {
    buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true
            
        }
    }
}
Mohamed Essam
  • 124
  • 1
  • 10
  • I have added minifyEnabled true, And when build is ok and generated apk file for me, But some code not work. Example like glide unable to load image from remote url – Noeurn Neang Jun 28 '19 at 03:46
  • minifyEnabled only detects and safely removes unused classes, fields, methods, and attributes from your app and its library dependencies, and also shortens the name of classes and members, which results in reduced DEX file sizes. it works perfectly and doesn't have any effect on code functionality, I use it in my apps and everything is good. You can read more about this tool from the link above. – Mohamed Essam Jun 28 '19 at 14:57
0

If you sign your app, it cannot be tampered with without invalidating the signature.

However, that is not sufficient to stop someone moding your code and then running it on a "rooted" device. Or similar.

In fact, there is nothing you can do to 100% prevent that. The best you have is to use an obfuscator, and hope that the hackers are not going to try hard.

There is no technical solution that will prevent a user from tampering with a 3rd-party app on any platform that they control. This is not an Android or Java specific problem. It applies for all user-controlled platforms and all programming languages.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216