I develop an app with Android Studio and I want to create different versions of the app.
I made two git-branches and tried to use the same properties-file with different URIs. But each time when I commit it or merge my branches URIs are unified.
May be I can use gradel settings somehow or you can give me another peice of advice how can I user different URI for different branches and not to rewrite them each time after commit and merge.
You can use Gradle Build types for this kind of task. See http://developer.android.com/tools/building/configuring-gradle.html for more information.
Add something like the following to your build.gradle file:
buildTypes {
debug {
buildConfigField "String", "URL", "www.aaaaaaaaa.com"
}
release {
buildConfigField "String", "URL", "www.bbbbbbbbb.com"
}
println "Applied basic configurations."
}
You can access this field via BuildConfig.URL
in the JavaCode of your app.
You need to make following changes within your gradle:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.