Reputation: 481
I have 2 modules in my app, one for the API, one for the app.
In the API module I define 2 API endpoint depending if the API is compiled in debug
or release
mode:
buildTypes {
all {
buildConfigField "String", "API_DEVICE_TYPE", "\"android-phone\""
}
debug {
buildConfigField "String", "API_ENDPOINT", "\"https://beta-api.company.com/\""
}
release {
buildConfigField "String", "API_ENDPOINT", "\"https://api.company.com/\""
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
In Android Studio's Build variant
panel I selected the debug variant for both app and API module. But when I press play/clean/rebuild/remove all build directory by hand/resync gradle, well whatever I do this is the release API which get compiled every time.
Any hint?
Tried with gradle build tools 2.1.0
and 2.2.0-aplha3
.
Upvotes: 0
Views: 997
Reputation: 481
Just add this code in your submodule build.gradle
// There is a limitation in gradle: You can't pick what submodule of app you want to compile your app with.
// This attribut define which build variant you want your api to be compiled against.
// https://sites.google.com/a/android.com/tools/tech-docs/new-build-system/user-guide#TOC-Library-Publication
defaultPublishConfig "debug"
Upvotes: 1