且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android应用程序的多个实例 - Git项目管理的***方法

更新时间:2023-11-22 21:00:52

所有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.

Android应用程序的多个实例 -  Git项目管理的***方法

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项目管理的***方法