简体   繁体   English

一个应用程序的开发和生产版本

[英]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开发了一个应用程序,并且想要创建该应用程序的不同版本。

  1. Development version should always use the test website www.aaaaaaaaa.com 开发版本应始终使用测试网站www.aaaaaaaaa.com
  2. Production version should use the release website www.bbbbbbbb.com 生产版本应使用发布网站www.bbbbbbbb.com

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.

相关问题 在一台设备上安装应用程序的生产和测试版本 - Installing a production and test version of an app on one device 应用在生产时崩溃,但在开发中却没有 - App crashes on production but not in development 在单个设备上开发和生产相同应用程序的版本 - Development and Production versions of the same app on a single device 如何在同一部手机中安装Apk开发和生产版本? - How to Install Apk Development and Production Version in the same phone? 通过代码检测应用是否为生产/发布版本 - Detect if App is Production/Release Version from Code 在动态生成的组件中创建 React Native 应用程序、开发和生产差异 - Create react native app, development and production differences in dynamically generated components 使用gradle自动更改App Environment(开发/生产...) - Use gradle to change App Environment ( development/ production…) automatically 是否可以检测到 android 应用程序是测试版还是生产版? - Is it possible to detect that an android app is either a beta version or production version? 在安装生产版本时安装应用程序的调试版本 - Installing Debug version of app while Production version is installed 如何在不删除已发布版本的情况下安装应用程序的开发版本? - How to install the development version of the app without removing the published version?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM