且构网

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

管理code /构建Android应用程序商店(谷歌/亚马逊/等)?

更新时间:2022-12-21 15:08:07

这是很容易做到的ADT(17版)的最新版本,虽然我觉得它使编译的时间长一点:

It's quite easy to do in the newest versions of ADT (version 17), though I do find it makes compilation a bit longer:

  1. 创建一个新的Andr​​oid项目( PROJ-A 的)
  2. 转到项目 - >属性,选择Android和检查是图书馆
  3. 将所有常用的code到的 PROJ-A 的,导入所有必要的库
  4. 创建一个新的Andr​​oid项目,谷歌播放(凸出-B 的)
  5. 转到项目 - >属性,选择Android和添加的 PROJ-A 的到库
  6. 在重复#4和5亚马逊版本
  1. Create a new Android project (proj-A)
  2. Go to Project->Properties, select Android, and check "Is Library"
  3. Move all your common code to proj-A, import all the necessary libraries
  4. Create a new Android project for Google Play (proj-B)
  5. Go to Project->Properties, select Android, and add Proj-A to the Library
  6. Repeat #4&5 for the Amazon version

如果你有一些变量,应设置不同的每个分项目(即布尔GOOGLE_PLAY_VERSION,使谷歌播放特定功能),你必须创建另一个项目为包含这些值,因为你不能有引用单项目另一个以循环方式。您可以通过添加以下步骤解决这个问题:

If you have some variables that should be set differently for each sub project (i.e. boolean GOOGLE_PLAY_VERSION to enable Google Play specific functions), you have to create another project to contain these values since you can't have projects that reference one-another in a circular fashion. You can solve this by adding the following steps:

  1. 所有的分项工程的具体变量拉成只是充当容器(S)的一个或多个类别为这些变量
  2. 创建一个虚拟的Java项目(的)
  3. 配置的 PROJ-A 的添加新的源链接的bin目录中的虚拟
  4. 添加在每个子项目的配置类与特定项目的修改
  5. 利润!
  1. Pull all of your sub-project specific variables into one or more Classes that just serves as container(s) for these variables
  2. Create a "dummy" Java project (dummy)
  3. Config proj-A to add a new Source link to the bin directory of dummy
  4. Add the config Classes in each sub-project with project-specific changes
  5. Profits!

请注意,在变量的虚拟的应该的不可以设置为决赛,否则会覆盖分项目的设置。

Note that the variables in dummy should not be set as final, otherwise it will override sub-project's setting.

这似乎是相当多的前期工作,但一直做得很不错,我尽可能的版本控制去。

This may seem like quite a bit of up-front work, but has worked quite well for me as far as version control goes.

编辑: 现在,与谷歌的举动,Android的工作室和放大器;摇篮,它可能是更好的移动到,如果你正在开始一个新的项目,如果要支持多个APK,看到Android开发网站的与摇篮#工作与构建生成项目变种。它绝对不伤害,才决定以评估该选项。

Now with Google's move to Android Studio & Gradle, it may be better to move to that if you are starting a new project if you want to support multiple APKs, see Android dev site's Building Your Project with Gradle#Work with build variants. It definitely doesn't hurt to evaluate that option before deciding.