Fat Monk
Fat Monk

Reputation: 2265

Where can I get the defaul proguard files for R8

I'm working on an app in Android Studio 3.6 and I've just realised that I seem to be missing the proguard-android.txt or proguard-android-optimize.txt and proguard-rules.pro files.

They are defined in my build.gradle (app) file:

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

but I do not have these files shwoing anywhere in my project tree or in the project folders.

I am using gradle 3.6.3 according to my build.gradle (ProjectName) file so I know that R8 will actually be used rather than ProGuard, but I understand (from https://developer.android.com/studio/build/shrink-code#keep-code) that R8 still uses the same files to define what should be optimized and what should be kept etc.

I want to make sure that my app is optimized and obfuscated but I also need to protect some code with -keep clauses which I believe need to go into the proguard-rules.pro file.

So, a couple of questions:

  1. Why do I not have these files?
  2. How do I get hold of the latest official defaul files as a starting point?

Upvotes: 1

Views: 683

Answers (1)

sgjesse
sgjesse

Reputation: 4628

The content of these files are built from the text files in https://android.googlesource.com/platform/tools/base/+/studio-master-dev/build-system/gradle-core/src/main/resources/com/android/build/gradle.

Based on the name of the argument to getDefaultProguardFile one or more of these resources are selected as configuration files in https://android.googlesource.com/platform/tools/base/+/studio-master-dev/build-system/gradle-core/src/main/java/com/android/build/gradle/ProguardFiles.java.

Upvotes: 1

Related Questions