Search code examples
javaandroidencode

How to encode package and function names in Android?


I want to change all package and function names to make my app harder to analyze. I reversed other apk and found what I want. But I don't know how to do like this. Please check attached image.enter image description here

Do I have to use any other tool or change this manually? Please give me a hint. Thanks!


Solution

  • In build.gradle of app module, enable minify to shorten and obfuscate your codes.

    buildTypes {
        release {
            // your code will be shortened and obfuscated by R8 compiler
            // in the release build of your app.
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    

    See also : https://developer.android.com/build/shrink-code