In my android application, I'm trying to run two sets of code so I can automatically change an advertising ID when I'm using Android Studio.
One for when I'm debugging in Android Studio, and one for when I build the .apk to upload to the play store.
I've been using if (BuildConfig.DEBUG)
, but how can I be sure that that will only be true when I'm actually debugging in Android Studio, and when I build the signed .apk it will be set to false? Where should I be configuring Gradle to know what build type to use, or is this automatically done when clicking Run?
Manifest.xml
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
debuggable true
}
}
When you generate an APK, the last screen will have a dropdown that lets you choose your build type. It defaults to "Release" but you can change it to "Debug."
That's how the APK is made a debug or release APK.
Basically, if you're running the app with the play button in the top right or with Shift+F10, it'll be built as a debug APK. If you generate a signed APK, it'll be a release APK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With