Build variants and debugging in release mode
Published:
https://developer.android.com/studio/build/build-variants
https://stackoverflow.com/questions/27321979/generating-unsigned-release-apk-with-android-studio
https://stackoverflow.com/questions/25001479/app-release-unsigned-apk-is-not-signed
By default Android Studio provides two build types / build variants; debug and release.
You can make the others too.
Why Build Variants?
- ‘Same’, or ‘Similar’ Codes, different characteristics displayed to users
- Different API Key for staging/debug and production/release
- No need to chanage the configurations prior the build, even for the various target SDK
Why Debugging in Release Mode
- No need to manually do copying the .apk file to the device.
How to
(Sign your app with your key)[https://developer.android.com/studio/publish/app-signing#sign_release]
you can use (KeyStore Explorer)[https://keystore-explorer.org/]Android Studio -> View -> Tool Windows -> Build Variants
or ClickBuild Variants
on the left bottom- Change the
Active Build variant
toRelease
- File -> Project Structure -> Choose Build Variants
- You can change the
Signing Config
- In
Modules
You can change the configurations there, like set theDebuggable
totrue
- In
Signing Configs
add the generated keystore to it. - Locate the
app/src
- Add the default Build Types
debug
andrelease
- Say you want to have different String value from xml. add the xml to the
res/values/yourfilename.xml
- Same goes to the other one
- The final stage is, you both have the same file(s), same path, in different parent folder
debug/res/values/yourfilename.xml
andrelease/res/values/yourfilename.xml
- Rebuild if it is needed and Run the app.