0
0
Android Kotlinmobile~10 mins

ProGuard and R8 optimization in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable R8 optimization in your Android app's build.gradle file.

Android Kotlin
android {
    buildTypes {
        release {
            minifyEnabled = [1]
        }
    }
}
Drag options to blanks, or click blank then click option'
Afalse
B"true"
Ctrue
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around true like "true" causes a syntax error.
Setting minifyEnabled to false disables code shrinking.
2fill in blank
medium

Complete the code to specify the ProGuard rules file in your build.gradle for release builds.

Android Kotlin
android {
    buildTypes {
        release {
            proguardFiles getDefaultProguardFile([1]), 'proguard-rules.pro'
        }
    }
}
Drag options to blanks, or click blank then click option'
A"proguard-default.txt"
B"proguard-android-optimize.txt"
C"proguard-rules.pro"
D"proguard-android.txt"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong file name disables optimization.
Omitting quotes causes syntax errors.
3fill in blank
hard

Fix the error in the ProGuard rule to keep all classes in the package com.example.app.models.

Android Kotlin
-keep class [1].** { *; }
Drag options to blanks, or click blank then click option'
Acom.example.app.models.**
Bcom.example.app.model
Ccom.example.app.models.*
Dcom.example.app.models
Attempts:
3 left
💡 Hint
Common Mistakes
Adding wildcards inside the package name causes errors.
Misspelling the package name prevents rules from applying.
4fill in blank
hard

Fill both blanks to keep all public void methods in the class com.example.app.utils.NetworkUtils.

Android Kotlin
-keepclassmembers class [1] {
    public [2] *;
}
Drag options to blanks, or click blank then click option'
Acom.example.app.utils.NetworkUtils
Bvoid
Cmethod
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'method' instead of a return type causes syntax errors.
Misspelling the class name prevents the rule from applying.
5fill in blank
hard

Fill both blanks to create a ProGuard rule that keeps all classes annotated with @Keep in the package com.example.app.

Android Kotlin
-keep @[1] class [2].** { *; }
Drag options to blanks, or click blank then click option'
Aandroidx.annotation.Keep
Bcom.example.app
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing annotation and package names.
Using incomplete package names.