lannyf
lannyf

Reputation: 11035

android, why library module with minifyEnabled false

Having a app which uses some libs. Saw the lib has

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

and the proguard-rules.pro has some rules to keep some classes.

My believe is since the R8 is by default on for the shrinking/obfuscation, and the minifyEnabled false will disable it. If that is true, does it mean the lib's aar will be built with no shrinking/obfuscation?

If the app by default with the R8 on, the app will do shrinking/obfuscation including the depended library?

Upvotes: 3

Views: 4279

Answers (1)

Ivan Gavrilovic
Ivan Gavrilovic

Reputation: 176

For a library project, minifyEnabled false means that the final AAR will not be processed with R8 i.e no code optimizations or dead code removal will be performed.

If an app project has minifyEnabled true, R8 will process app code, all external (Maven) libraries, and local library projects, and it will use rules specified in the application to do that.

As a general rule, R8 runs only when the final binary is produced, either AAR or APK or app bundle, and whether it is enabled or not is specified in the project that produces that artifact (library or application project).

Upvotes: 8

Related Questions