Search code examples
javaandroidminify

how Android source code minify and obfuscate?


I had done my apps, any idea to minify the Android and Java code? can it save the apk file size and improve performance? compare to unminify source code.


Solution

  • Enable shrinkResources in your build type. Note that it requires minify to be enabled. In your Gradle file:

    android {
        buildTypes {
            release {
                minifyEnabled true
                shrinkResources true
            }
        }
    }
    

    The accepted answer is now outdated, so I added this answer if someone else stumbles upon this question.