Android应用程序的多个实例 - Git项目管理的最佳方法 [英] multiple instances of android app - git project management best approach

查看:203
本文介绍了Android应用程序的多个实例 - Git项目管理的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这都将有多个实例的应用程序。实例将在一些资源,其可以分为两组不同:

I have an app which is going to have multiple instances. The instances will differ in some resources, which can be divided into two groups:


  1. 的区别仅在于(联合国)评论code,整个code是present

    • 颜色

    • 字符串

    • 在布局小的差异(例如,在一个实例中某些组件将不复存在,在另一种情况下,他们将是可见的,但code保持)


  • 包名

  • 可绘制

  • 在RES证书/ RAW(所有证书不得储存在那里,只有在特定的情况下)

什么是处理这些需求的最佳方法呢?使用不同的混帐分支机构?

我使用git(smartgit客户端)。我想,当我使用不同的情况下的不同分支的所有要求可以得到满足。但恐怕这种做法不会为第二组的工作 - 完全替代(名,文件)。有什么建议?

I use git (smartgit client). I guess that all requirements could be met when I use different branches for different instances. But I am afraid that this approach won't work for second group - complete substitution (name, files). Any suggestions?

PS:据我了解,当添加新的功能,我需要一些主分支合并为所有其他部门。

PS: I understand that When adding new features I need to merge from some master branch into all other branches.

推荐答案

所有git的方法后,没有这种权利。与摇篮只是做正确的事:

After all git approach wasn't that right. Building multiple app instances (product flavours) with Gradle was just the right thing to do:

1)每个应用实例的具体文件和资源

1) Specific files and resources per the instance of app

颜色字符串位于资源文件:项目/模块/ src目录/ INSTANCE_NAME / RES /价值/ instance_name_cfg.xml

colors and strings are located in resource files: Project/module/src/instance_name/res/values/instance_name_cfg.xml.

布局位于:项目/模块/ src目录/ INSTANCE_NAME / RES /布局/ instance_name_cfg.xml

的Java code 位于:项目/模块/ src目录/ INSTANCE_NAME / JAVA / package.name / MyClass.java

绘项目(PNG图片)位于:项目/模块/ src目录/ INSTANCE_NAME / RES /绘制/ ic_launcher 图片是只有在不同的文件夹相同的路径(绘制,华电国际,...)

drawables (PNG images) are located in: Project/module/src/instance_name/res/drawable/, ic_launcher images are in the same path only in different folders (drawable-hdpi,...)

常见的文件和资源位于项目/模块/ src目录/主/ 文件夹中。

2)在第一个画面中,整个文件结构。

2) In the first picture there is the whole file structure.

实例是在我的情况下,城市(达曼,吉达,布拉格,阅读)。截图是从Android的工作室,在那里你可以切换构建变种(口味)拍摄 - 在图片的底部

Instances are in my case cities (Dammam, Jeddah, Prague, Reading). Screenshots are taken from Android Studio, where you can switch build variants (flavours) - at the bottom of the picture.

3)在第二张照片就有的build.gradle文件的片段。

3) In the second picture there is a fragment of the build.gradle file.

混合应用程序(实例)的资源是相当强大的。正如你可以在下面的图片中看到,资源,java文件,甚至清单文件可以一起在指令中的 sourceSets 相结合。例如达曼和吉达有每个实例相同的java文件,一些常见的资源和特定资源。在sourceSets使用实例的名称(例如达曼)必须precede申报指令中的 productFlavours

Mixing app (instance) resources is quite powerful. As you can see in the picture below, resources, java files and even manifest files could be combined together in directive sourceSets. For example Dammam and Jeddah have the same java files, some common resources and specific resources per instance. Using name of instance (e.g. dammam) in sourceSets must precede declaration in directive productFlavours.

这篇关于Android应用程序的多个实例 - Git项目管理的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆