[英]development and production version of one app
I develop an app with Android Studio and I want to create different versions of the app. 我使用Android Studio开发了一个应用程序,并且想要创建该应用程序的不同版本。
I made two git-branches and tried to use the same properties-file with different URIs. 我做了两个git分支,并尝试将同一属性文件与不同的URI一起使用。 But each time when I commit it or merge my branches URIs are unified.
但是每次我提交或合并分支时,URI都是统一的。
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. 可能是我可以以某种方式使用Gradel设置,或者您可以给我另一种建议,即如何为不同的分支使用不同的URI,而不必在每次提交和合并后都重写它们。
You can use Gradle Build types for this kind of task. 您可以将Gradle Build类型用于此类任务。 See http://developer.android.com/tools/building/configuring-gradle.html for more information.
有关更多信息,请参见http://developer.android.com/tools/building/configuring-gradle.html 。
Add something like the following to your build.gradle file: 在您的build.gradle文件中添加以下内容:
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. 您可以通过应用程序JavaCode中的
BuildConfig.URL
访问此字段。
You need to make following changes within your gradle: 您需要在gradle中进行以下更改:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.