0
0
Android Kotlinmobile~20 mins

ProGuard and R8 optimization in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ProGuard and R8 Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of ProGuard in Android development?
Choose the main reason developers use ProGuard when building Android apps.
ATo generate app screenshots for the Play Store listing
BTo add new UI components automatically during build
CTo increase the app's runtime speed by changing the CPU architecture
DTo shrink and obfuscate the app code to reduce APK size and protect code
Attempts:
2 left
💡 Hint
Think about what happens to your app code before publishing it.
ui_behavior
intermediate
2:00remaining
What happens to your app UI if R8 removes a class used only in layout XML?
If R8 optimization removes a class that is only referenced in your layout XML files but not directly in Kotlin code, what is the likely result when you run the app?
AThe app UI shows a blank screen but no crash
BThe app crashes at runtime with a ClassNotFoundException
CThe app runs normally without any UI changes
DThe app shows a compile-time error and does not build
Attempts:
2 left
💡 Hint
Consider how R8 detects code usage and what happens if a needed class is missing at runtime.
lifecycle
advanced
2:00remaining
How does enabling R8 affect app build lifecycle and debugging?
When you enable R8 in your Android project, which of the following is true about the build lifecycle and debugging experience?
ABuild time increases slightly and debugging obfuscated code requires mapping files
BBuild time decreases and debugging is easier because code is simplified
CBuild time is unaffected and debugging works normally without changes
DBuild time increases drastically and debugging is impossible
Attempts:
2 left
💡 Hint
Think about what happens when code is obfuscated and how developers debug crashes.
navigation
advanced
2:00remaining
Which ProGuard rule prevents removal of classes used in Android Navigation XML?
You use Android Navigation component with fragments declared only in navigation XML. Which ProGuard rule keeps these fragment classes from being removed by R8?
A-keep class * extends android.app.Activity { <init>(); }
B-keep class ** { *; }
C-keep class * extends androidx.fragment.app.Fragment { <init>(); }
D-keep class * implements android.os.Parcelable { <init>(); }
Attempts:
2 left
💡 Hint
Fragments used only in XML need to be kept by their class inheritance.
📝 Syntax
expert
2:00remaining
What is the output of this ProGuard keep rule effect on R8 optimization?
Given this ProGuard rule: -keepclassmembers class com.example.MyClass { public void myMethod(); } What effect does this have on R8 optimization?
Android Kotlin
-keepclassmembers class com.example.MyClass { public void myMethod(); }
AKeeps only the method 'myMethod' in MyClass from being removed or renamed
BKeeps the entire MyClass and all its members from removal or renaming
CRemoves 'myMethod' but keeps the rest of MyClass intact
DHas no effect; R8 ignores this rule
Attempts:
2 left
💡 Hint
Focus on what 'keepclassmembers' means compared to 'keep'.