Complete the code to enable R8 optimization in your Android app's build.gradle file.
android {
buildTypes {
release {
minifyEnabled = [1]
}
}
}Setting minifyEnabled = true enables R8 to shrink and optimize your app code during release builds.
Complete the code to specify the ProGuard rules file in your build.gradle for release builds.
android {
buildTypes {
release {
proguardFiles getDefaultProguardFile([1]), 'proguard-rules.pro'
}
}
}The getDefaultProguardFile("proguard-android-optimize.txt") loads the default optimized ProGuard rules for Android.
Fix the error in the ProGuard rule to keep all classes in the package com.example.app.models.
-keep class [1].** { *; }
The correct package name is com.example.app.models. The .** after it keeps all classes recursively.
Fill both blanks to keep all public void methods in the class com.example.app.utils.NetworkUtils.
-keepclassmembers class [1] { public [2] *; }
The class name is com.example.app.utils.NetworkUtils. The return type void matches public methods with no return value.
Fill both blanks to create a ProGuard rule that keeps all classes annotated with @Keep in the package com.example.app.
-keep @[1] class [2].** { *; }
The annotation is androidx.annotation.Keep. The package is com.example.app. This rule keeps all classes in that package annotated with @Keep.