{"id":2971,"date":"2017-11-17T14:23:50","date_gmt":"2017-11-17T14:23:50","guid":{"rendered":"http:\/\/support.loginextsolutions.com\/?p=2971"},"modified":"2026-01-28T09:37:55","modified_gmt":"2026-01-28T09:37:55","slug":"internationalization-4","status":"publish","type":"post","link":"https:\/\/support.loginextsolutions.com\/index.php\/2017\/11\/17\/internationalization-4\/","title":{"rendered":"ProGuard"},"content":{"rendered":"\n\n\n\t<div class=\"dkpdf-button-container\" style=\" text-align:left \">\n\n\t\t<a class=\"dkpdf-button\" href=\"\/index.php\/wp-json\/wp\/v2\/posts\/2971?pdf=2971\" target=\"_blank\"><span class=\"dkpdf-button-icon\"><i class=\"fa fa-file-pdf-o\"><\/i><\/span> Download PDF<\/a>\n\n\t<\/div>\n\n\n\n\n\n\n<div class=\"segment segment-reversed\">\n<div class=\"container\">\n<div class=\"segment-content\">\n<div class=\"segment-inner-content main\">\n<div class=\"loginext-articles\">\n<div><\/div>\n<article>ProGuard is an open-source command-line tool that helps you shrink, optimize, and obfuscate Java code. It can detect and remove unused instructions and optimize bytecode, making your Android application smaller and harder to reverse engineer. ProGuard runs automatically when you build your app in release mode and is distributed as part of the Android SDK.<br data-start=\"576\" data-end=\"579\">It is licensed under the GNU General Public License, version 2.<p><\/p>\n<h4>ProGuard Features<\/h4>\n<p><strong><span style=\"text-decoration: underline;\">Obfuscation<\/span><br>\n<\/strong><\/p>\n<p>ProGuard obfuscates Java and Android programs by renaming classes, fields, and methods using meaningless names, making it harder to reverse-engineer the final application.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Optimization<\/strong><\/span><\/p>\n<p>Besides removing unused instructions from the compiled bytecode, ProGuard optimizes it using techniques, such as control flow analysis, data-flow analysis, partial evaluation, static single assignment, global value numbering, and liveness analysis.<\/p>\n<p data-start=\"2603\" data-end=\"2623\"><span style=\"text-decoration: underline;\"><strong>Code Shrinking<\/strong><\/span><\/p>\n<p data-start=\"2624\" data-end=\"2708\">Removes unused code (classes, methods, fields) including from third-party libraries.<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Usage<\/strong><\/span><\/p>\n<p>Works with&nbsp;Java Micro Edition&nbsp;and&nbsp;Android.<\/p>\n<h4><strong>Code and Resource Shrinking<\/strong><\/h4>\n<p>Code shrinking is available with ProGuard, which detects and removes unused classes, fields, methods, and attributes from your packaged app, including those from included code libraries. ProGuard also optimizes the bytecode, removes unused code instructions, and obfuscates the remaining classes, fields, and methods with short names. The obfuscated code makes your APK difficult to reverse engineer, which is especially valuable when your app uses security-sensitive features, such as licensing verification.<\/p>\n<p>Resource shrinking is available with the Android plugin for Gradle, which removes unused resources from your packaged app, including unused resources in code libraries. It works in conjunction with code shrinking such that once unused code has been removed, any resources no longer referenced can be safely removed as well.<\/p>\n<p>We can use ProGuard for code and resource shrink as follows:<\/p>\n<ol>\n<li>Code Shrink:<br>\nTo enable code shrinking with ProGuard, set minifyEnabled = true to the appropriate build type in our build.gradle file. For example, the following snippet from a build.gradle file enables code shrinking for the release build:<br>\n<code>android {<br>\n&amp;nbsp&amp;nbsp&amp;nbspbuildTypes {<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsprelease {<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbspminifyEnabled true<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbspproguardFiles getDefaultProguardFile(\u2018proguard-android.txt\u2019), \u2018proguard-rules.pro\u2019<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp}<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp}<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp\u2026<br>\n}<br>\n<\/code><\/li>\n<li>Resource Shrink:Resource shrinking works only in conjunction with code shrinking. After the code<br>\nshrinker removes all unused code, the resource shrinker can identify which resources the app still uses. This is especially true when you add code libraries that include resources\u2014you must remove unused library code so the library resources become unreferenced and, thus, removable by the resource shrinker. To enable resource shrinking, set the shrink Resources property to true in your build.gradle file<br>\n(alongside minifyEnabled for code shrinking). For example:<p><\/p>\n<p><code>android {<br>\n&amp;nbsp&amp;nbsp&amp;nbspbuildTypes {<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsprelease {<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbspshrinkResources true<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbspminifyEnabled true<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbspproguardFiles getDefaultProguardFile(\u2018proguard-android.txt\u2019), \u2018proguard-rules.pro\u2019<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp}<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp}<br>\n&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp&amp;nbsp\u2026<br>\n}<br>\n<\/code><\/p><\/li>\n<\/ol>\n<h3>Common ProGuard Rules<\/h3>\n<ul>\n<li><strong>KEEP: <\/strong>Preserve specified classes and class members from being obfuscated.<br>\n<code><br>\n-keep class com.loginext.tracknext.samsung_sdk.** {*;}<br>\n-keep class com.loginext.tracknext.samsung_sdk.GPSChangeReciever {*;}<br>\n-keep class android.app.enterprise.** {*;}<br>\n-keep class com.volley.** { *; }<br>\n-keep class com.google.firebase.iid.** { *; }<br>\n-keep class com.google.firebase.messaging.FirebaseMessagingService { *; }<br>\n-keep interface com.android.volley.* { *; }<br>\n-keep class org.apache.*<br>\n-keep class android.support.v4.app.** { *; }<br>\n-keep interface android.support.v4.app.** { *; }<br>\n-keep class android.support.v4.** { *; }<br>\n-keep class android.support.v7.internal.** { *; }<br>\n-keep interface android.support.v7.internal.** { *; }<br>\n-keep class android.support.v7.** { *; }<br>\n-keep class com.google.android.gms.measurement.** { *; }<br>\n-keep class com.google.android.gms.iid.** { *; }<br>\n-keep class com.google.android.gms.location.** { *; }<br>\n<\/code><\/li>\n<li><strong>DONTWARN:: <\/strong>Don&#8217;t warn about unresolved references at all. Suppresses warnings about unresolved references, especially useful for backward compatibility or optional dependencies:<br>\n<code><br>\n-dontwarn okio.**<br>\n-dontwarn android.support.**<br>\n-dontwarn com.google.ads.**<br>\n-dontwarn org.apache.**<br>\n-dontwarn android.support.v4.**<br>\n-dontwarn android.support.v7.**<br>\n-dontwarn com.google.android.gms.location.**<br>\n-dontwarn com.google.android.gms.iid.**<br>\n-dontwarn com.google.android.gms.measurement.**<br>\n<\/code><\/li>\n<\/ul>\n<p data-start=\"4124\" data-end=\"4408\">ProGuard plays a crucial role in protecting and optimizing Android applications. By enabling both code and resource shrinking, and configuring rules such as <code data-start=\"4285\" data-end=\"4292\">-keep<\/code> and <code data-start=\"4297\" data-end=\"4308\">-dontwarn<\/code>, you can significantly reduce APK size and protect sensitive logic from reverse engineering.<\/p>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Download PDF ProGuard is an open-source command-line tool that helps you shrink, optimize, and obfuscate Java code. It can detect and remove unused instructions and optimize bytecode, making your Android application smaller and harder to reverse engineer. ProGuard runs automatically &hellip; <a href=\"https:\/\/support.loginextsolutions.com\/index.php\/2017\/11\/17\/internationalization-4\/\">Continued<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[],"tags":[3011,3013,3015,3017,3018,3019,3020],"_links":{"self":[{"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/posts\/2971"}],"collection":[{"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/comments?post=2971"}],"version-history":[{"count":16,"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/posts\/2971\/revisions"}],"predecessor-version":[{"id":30534,"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/posts\/2971\/revisions\/30534"}],"wp:attachment":[{"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/media?parent=2971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/categories?post=2971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/support.loginextsolutions.com\/index.php\/wp-json\/wp\/v2\/tags?post=2971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}