A build variant is a combination of a build type and a product flavor that defines how the app is built and packaged. It lets you create different versions of your app, like debug and release.
Click to reveal answer
beginner
What is the main difference between debug and release build types?
The debug build is for testing and includes debugging tools and logs. The release build is optimized, signed, and ready for publishing to users.
Click to reveal answer
intermediate
Why do we use signingConfigs in the release build?
Signing configs provide the digital signature needed to verify the app's identity when publishing. Release builds must be signed to be accepted by app stores.
Click to reveal answer
intermediate
How can you customize the app behavior for debug and release builds?
You can use BuildConfig.DEBUG in code to check if the app is running a debug build and change behavior like enabling logs or test features.
Click to reveal answer
beginner
What Gradle file section defines build types like debug and release?
The android { buildTypes { ... } } block in the build.gradle file defines build types and their settings.
Click to reveal answer
Which build variant is typically used for testing with debugging tools enabled?
Adebug
Brelease
Cproduction
Dstaging
✗ Incorrect
The debug build variant includes debugging tools and is used for testing.
What must a release build have to be accepted by the Google Play Store?
ADebug logs enabled
BUnoptimized code
CExtra test code
DSigned with a release key
✗ Incorrect
Release builds must be signed with a release key to verify the app's identity.
Where do you define build types like debug and release in an Android project?
Abuild.gradle (Module)
Bsettings.gradle
CAndroidManifest.xml
Dproguard-rules.pro
✗ Incorrect
Build types are defined in the module-level build.gradle file inside the android block.
Which code snippet checks if the app is running a debug build?
ABuildType.RELEASE
BBuildVariant.DEBUG
CBuildConfig.DEBUG
DBuildConfig.RELEASE
✗ Incorrect
BuildConfig.DEBUG is a boolean that is true for debug builds.
What is a common use of the debug build variant?
APublishing to app stores
BTesting and debugging
COptimizing performance
DSigning with release keys
✗ Incorrect
Debug builds are used for testing and debugging during development.
Explain the purpose of build variants in Android and how debug and release builds differ.
Think about why you need different versions of your app during development and publishing.
You got /4 concepts.
Describe how you can customize app behavior based on the build variant in Kotlin code.
Consider how your app might behave differently when testing versus when users install it.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of the debug build variant in Android development?
easy
A. To publish the app on the Play Store
B. To test the app with debugging tools enabled
C. To reduce the app size for faster downloads
D. To disable all logging and debugging features
Solution
Step 1: Understand build variant roles
The debug variant is designed for developers to test and debug the app during development.
Step 2: Compare with release variant
The release variant is optimized and signed for publishing, unlike debug.
Final Answer:
To test the app with debugging tools enabled -> Option B
Quick Check:
Debug variant = testing with debugging [OK]
Hint: Debug variant is for testing, release is for publishing [OK]
Common Mistakes:
Confusing debug with release variant
Thinking debug is for publishing
Assuming debug disables logging
2. Which of the following is the correct way to specify a release build variant in the build.gradle file?
easy
A. buildVariants { debug { minifyEnabled false } }
B. buildVariants { release { minifyEnabled true } }
C. buildTypes { release { minifyEnabled false } }
D. buildTypes { debug { minifyEnabled true } }
Solution
Step 1: Identify correct block name
The correct block to define build variants is buildTypes, not buildVariants.
Step 2: Check release variant syntax
Inside buildTypes, release can have minifyEnabled set to true or false. buildTypes { release { minifyEnabled false } } uses correct syntax with minifyEnabled false.
A. minifyEnabled should be false for debug builds to avoid obfuscation
B. proguardFiles cannot be used in release builds
C. minifyEnabled must be true for debug builds
D. The buildTypes block is missing a closing brace
Solution
Step 1: Understand minifyEnabled purpose
Minify (obfuscation) is usually enabled in release builds to shrink and protect code.
Step 2: Check debug build settings
Enabling minify in debug builds is uncommon and can make debugging harder.
Final Answer:
minifyEnabled should be false for debug builds to avoid obfuscation -> Option A
Quick Check:
Debug builds usually disable minify [OK]
Hint: Disable minify in debug to ease debugging [OK]
Common Mistakes:
Enabling minify in debug builds
Thinking proguardFiles are invalid in release
Missing braces in buildTypes block
5. You want to create a new build variant called staging that behaves like release but with a different application ID and no code shrinking. Which build.gradle snippet correctly achieves this?