AAD Android Build System, Gradle & App Deployment 2 — Questions and Answers
Question 1: What is an Android App Bundle (AAB) and how does it differ from an APK?
- An AAB is processed by the Play Store to generate optimized APKs per device; APK is installed directly on devices (Correct answer)
- An AAB is installed directly on devices; APK is used only for local testing
- Both AAB and APK install directly, but AAB supports more CPU architectures
- An AAB is required only for Wear OS and Android TV apps
Correct answer: An AAB is processed by the Play Store to generate optimized APKs per device; APK is installed directly on devices
An Android App Bundle (AAB) is uploaded to the Play Store, which generates split APKs tailored to each device's configuration (architecture, screen density, language), reducing download size.
Question 2: What is the purpose of ProGuard/R8 in a release build?
- To generate the APK signing keystore automatically
- To convert Kotlin source code to Java before compilation
- To manage third-party library version conflicts
- To shrink, optimize, and obfuscate the app's bytecode (Correct answer)
Correct answer: To shrink, optimize, and obfuscate the app's bytecode
ProGuard/R8 performs code shrinking (removes unused code), optimization (improves bytecode efficiency), and obfuscation (renames classes/methods) during the release build process.
Question 3: Which Gradle dependency scope makes a library available at compile time but excludes it from the final APK?
- implementation
- api
- compileOnly (Correct answer)
- runtimeOnly
Correct answer: compileOnly
`compileOnly` makes the dependency available to the compiler but excludes it from the output APK/AAR, useful for annotation processors and other compile-time-only tools.
Question 4: What must be changed before publishing an app update to the Google Play Store?
- The `versionName` must be set to a higher semantic version
- The `versionCode` must be incremented from the previously published release (Correct answer)
- A new keystore must be generated for each release submission
- The app must be recompiled against a higher `compileSdkVersion`
Correct answer: The `versionCode` must be incremented from the previously published release
The `versionCode` must be incremented with each new Play Store submission; the Play Store rejects updates with a `versionCode` equal to or lower than the currently published version.
Question 5: What is the purpose of `local.properties` in an Android project?
- To define product flavors and build types for the project
- To store machine-specific configuration like the Android SDK path, excluded from version control (Correct answer)
- To configure Gradle task dependency ordering
- To specify the app's runtime permissions
Correct answer: To store machine-specific configuration like the Android SDK path, excluded from version control
`local.properties` stores environment-specific configuration (like the `sdk.dir` path) that varies per developer machine and should not be committed to version control.
Question 6: How does the `api` dependency configuration differ from `implementation` in Gradle?
- `api` dependencies are available only at runtime; `implementation` are compile-time only
- `api` exposes the dependency to consumers of your library module; `implementation` keeps it internal (Correct answer)
- `api` is used for test dependencies; `implementation` is for production code only
- There is no functional difference; they are interchangeable
Correct answer: `api` exposes the dependency to consumers of your library module; `implementation` keeps it internal
`api` makes the dependency part of your module's public API (visible to dependent modules), while `implementation` hides it, preventing leakage and improving build performance.
Question 7: What does `buildConfigField` in Gradle allow developers to do?
- Configure the signing certificate for a specific build type
- Define build-type-specific Gradle JVM arguments
- Inject a constant into the generated `BuildConfig` class accessible in app code at runtime (Correct answer)
- Override default manifest values for a specific build variant
Correct answer: Inject a constant into the generated `BuildConfig` class accessible in app code at runtime
`buildConfigField` injects a typed constant (String, Boolean, int, etc.) into the generated `BuildConfig` class, allowing build-variant-specific values to be accessed directly in Kotlin/Java code.
What is an Android App Bundle (AAB) and how does it differ from an APK?