更新时间:2022-12-21 15:03:38
在最新版本的 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:
如果您有一些变量应该为每个子项目设置不同的(即布尔值 GOOGLE_PLAY_VERSION 以启用 Google Play 特定功能),您必须创建另一个项目来包含这些值,因为您不能拥有引用一个的项目 -另一个以循环方式.您可以通过添加以下步骤来解决此问题:
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:
注意dummy中的变量不要设为final,否则会覆盖子项目的设置.
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.
现在随着 Google 转向 Android Studio &Gradle,如果您要支持多个 APK,***开始一个新项目,请参阅 Android 开发站点的 使用 Gradle 构建您的项目#使用构建变体.在决定之前评估该选项绝对没有坏处.
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.