Android Studio - 多个 android 应用程序在单个项目中具有共同的依赖项
Android Studio - Multiple android apps with common dependencies in a single project
我有两个不同的 android 应用程序 A 和 B。
A和B是同一个项目中的模块
两者都依赖于库模块 Z,后者本身依赖于另外两个库模块 X 和 Y
- A -> Z
- B -> Z
Z -> X, Y
现在这个 question 的公认答案是一个 Android Studio 项目不能有多个应用程序。
奇怪的是,我能够在我的 phone 上很好地构建这两个应用程序(在一个 android 工作室项目中)并且 运行 它们。我在这里遗漏了一些明显的东西吗?
一个 android studio 项目可以包含多个应用程序吗?
- 如果答案是否定的,为什么?
- 如果答案是肯定的,有什么问题吗?
一个 Android 项目确实可以有多个应用程序,但如果它们不相关,您可能会争论在一个项目中拥有多个应用程序的好处。
无论如何,如果您有同一个应用程序的多个版本但它们之间存在一些差异(目标设备、品牌...),这是完全合理的。在这种情况下,Gradle 构建系统允许您拥有 构建变体 (每个构建变体都是 产品风味 和构建类型)。根据官方文档(Configuring Gradle Builds > Work with build variants):
The build system uses product flavors to create different product versions of your app. Each product version of your app can have different features or device requirements. The build system also uses build types to apply different build and packaging settings to each product version. Each product flavor and build type combination forms a build variant. The build system generates a different APK for each build variant of your app.
我有两个不同的 android 应用程序 A 和 B。 A和B是同一个项目中的模块
两者都依赖于库模块 Z,后者本身依赖于另外两个库模块 X 和 Y
- A -> Z
- B -> Z
Z -> X, Y
现在这个 question 的公认答案是一个 Android Studio 项目不能有多个应用程序。
奇怪的是,我能够在我的 phone 上很好地构建这两个应用程序(在一个 android 工作室项目中)并且 运行 它们。我在这里遗漏了一些明显的东西吗?
一个 android studio 项目可以包含多个应用程序吗?
- 如果答案是否定的,为什么?
- 如果答案是肯定的,有什么问题吗?
一个 Android 项目确实可以有多个应用程序,但如果它们不相关,您可能会争论在一个项目中拥有多个应用程序的好处。
无论如何,如果您有同一个应用程序的多个版本但它们之间存在一些差异(目标设备、品牌...),这是完全合理的。在这种情况下,Gradle 构建系统允许您拥有 构建变体 (每个构建变体都是 产品风味 和构建类型)。根据官方文档(Configuring Gradle Builds > Work with build variants):
The build system uses product flavors to create different product versions of your app. Each product version of your app can have different features or device requirements. The build system also uses build types to apply different build and packaging settings to each product version. Each product flavor and build type combination forms a build variant. The build system generates a different APK for each build variant of your app.