After upgrading to Android Gradle plugin 3.4.0, a basic class no longer gets obfuscated.
The following basic steps can reproduce the problem:
- In Android Studio create a new empty project
- In
app/build.gradlechangeminifyEnabledtotrue Create the following class,
ProguardTestClass.java:public class ProguardTestClass { public interface ProguardTestInnerInterface { void proguardTestCallback(String message); } public static void proguardTestMethod(String input, ProguardTestInnerInterface impl) { impl.proguardTestCallback("proguardTestMethod received input=[" + input + "]"); } }Refer to the class from
MainActivity.java:public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ProguardTestClass.proguardTestMethod("MainActivity's ProguardTestClass", new ProguardTestClass.ProguardTestInnerInterface() { @Override public void proguardTestCallback(String message) { Log.d(TAG, "Proguard test: " + message); } }); } }Confirm that it's using Android Gradle plugin 3.4.0 in
build.gradle- Confirm that it's using
gradle-5.1.1ingradle/wrapper/gradle-wrapper.properties - Open a Terminal window in the Terminal tab
- Run
./gradlew clean build - Run
find . -name mapping.txt | xargs grep "ProguardTestClass -> "
Expected output:
com.example.proguardgradleplugin340.ProguardTestClass -> com.example.proguardgradleplugin340.a:
Actual output:
app/build/outputs/mapping/release/mapping.txt does not mention any renaming of ProguardTestClass.
To see that prior Android Gradle plugin versions could produce the expected output, repeat the steps above but point to prior versions of Android Gradle plugin and Gradle:
- Change to Android Gradle plugin 3.3.2 in
build.gradle - Change to
gradle-4.10.1ingradle/wrapper/gradle-wrapper.properties
I tried to investigate by looking into other diagnostic files that we used to get from Proguard, but they're no longer output (at least not by default anyway):
find . -name seeds.txt
find . -name usage.txt
I also checked the Android Gradle plugin 3.4.0 release notes and found out that it replaced Proguard in favor of a new technology that "integrates desugaring, shrinking, obfuscating, optimizing, and dexing all in one step".