My Android Studio version is 2.3.3
In my Android app gradle build, I have explictly defined different server_url
string values for debug type and release type:
buildTypes {
debug {
resValue "string", "server_url", "https://myserver.debug.com/"
}
release {
resValue "string", "server_url", "https://myserver.com/"
...
}
}
In my code, I get the string value by:
String url = context.getString(R.string.server_url);
I connected my Android phone to my laptop. The Android studio toolbar looks like this:
I also selected build variants to be "debug":
I click the , the app is running on my phone, however, it uses server_url
value defined in release type. Why?
(Under build/generated/res/resValues/debug/generated.xml
& build/generated/res/resValues/release/generated.xml
I see those values, no problem there eihter.)
==== Update ===
Adding defaultPublishConfig 'debug'
fixed the issue (Thanks @Ulug Toprak), but I am still wondering why Android Studio doesn't work without it though I have set Build Variant to "Debug". Maybe a bug in Android Studio?
clean
the project before run? – IronydefaultPublishConfig "debug"
to your build.gradle – PitpublishNonDefault
in the library build.gradle set the false by any chance? – Pit