Challenge - 5 Problems
ProGuard and R8 Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What is the primary purpose of ProGuard in Android development?
Choose the main reason developers use ProGuard when building Android apps.
Attempts:
2 left
💡 Hint
Think about what happens to your app code before publishing it.
✗ Incorrect
ProGuard shrinks the app by removing unused code and obfuscates it to make reverse engineering harder, reducing APK size and improving security.
❓ ui_behavior
intermediate2: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?
Attempts:
2 left
💡 Hint
Consider how R8 detects code usage and what happens if a needed class is missing at runtime.
✗ Incorrect
R8 removes unused classes based on code references. If a class is only referenced in XML and not kept, it will be removed, causing a runtime crash when the UI tries to inflate it.
❓ lifecycle
advanced2: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?
Attempts:
2 left
💡 Hint
Think about what happens when code is obfuscated and how developers debug crashes.
✗ Incorrect
R8 adds optimization steps increasing build time slightly. Obfuscated code changes names, so debugging requires mapping files to translate stack traces back to original code.
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?
Attempts:
2 left
💡 Hint
Fragments used only in XML need to be kept by their class inheritance.
✗ Incorrect
Fragments used in navigation XML are instantiated by class name at runtime. The rule keeping all classes extending Fragment with a constructor prevents R8 from removing them.
📝 Syntax
expert2: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(); }Attempts:
2 left
💡 Hint
Focus on what 'keepclassmembers' means compared to 'keep'.
✗ Incorrect
'-keepclassmembers' keeps only the specified members (methods/fields) from removal or renaming but allows the class itself to be removed if unused.