Android的工作室 - 多个Android应用包含公共依赖于一个单一的项目 [英] Android Studio - Multiple android apps with common dependencies in a single project

查看:152
本文介绍了Android的工作室 - 多个Android应用包含公共依赖于一个单一的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个不同的Andr​​oid应用程序A和B.
A和B在同一个项目模块

都对库模Z的依赖本身依赖于另外两个库模块X和Y


  • 系统 - >以Z

  • B - >以Z


  

以Z - > X,Y


现在接受的答案,这<一个href=\"http://stackoverflow.com/questions/32419621/can-we-have-multiple-apps-in-one-android-studio-project\">question说,一个单一的Andr​​oid Studio项目不能有多个应用程序。

奇怪的是,我能够建立这两个应用程序(在一个单一的机器人工作室项目)和我的手机pretty运行得很好。我失去了一些东西明显在这里?

可以将单个机器人工作室项目包含多个应用程序?


  1. 如果答案是否定的,为什么呢?

  2. 如果答案是肯定的,是否有任何渔获?


解决方案

一个单一的Andr​​oid项目确实可以有多个应用程序,虽然你可能会说有关,如果他们是不相关的一个项目有几个应用程序所带来的好处。

无论如何,这是完全合理的情况下,你有其中的一些差异同一应用程序的多个版本(目标设备,品牌...)。在这种情况下,摇篮构建系统,可以让你有打造变种的(每个构建变体是组合的的产品风味的和的生成类型的) 。根据官方文档(配置摇篮构建>与构建工作变种


  

构建系统使用产品的口味来创建应用程序的不同的产品版本。应用的每个产品版本可以有不同的功能或设备的要求。构建系统还使用生成类型采用不同的构建和打包设置每个产品的版本。每个产品的味道和构建类型组合形成一个构建变量。构建系统产生不同的APK为您的应用程序的每个版本的变种。


I have two different android apps A and B. A and B are modules in the same project

Both have a dependency on a library module Z which itself depends on two other library modules X and Y

  • A -> Z
  • B -> Z

Z -> X, Y

Now the accepted answer to this question says that a single Android Studio project cannot have multiple apps.

Strangely I am able to build these two apps (in a single android studio project) and run them on my phone pretty well. Am I missing something obvious here ?

Can a single android studio project contain multiple apps ?

  1. If the answer is NO, why ?
  2. If the answer is YES, are there any catches ?

解决方案

A single Android project can indeed have multiple apps, although you could argue about the benefits of having several apps in a single project if they are unrelated.

Anyway, this is perfectly reasonable in case you have several versions of the same app with some differences among them (target devices, branding...). In that case the Gradle build system allows you to have build variants (each build variant being a combination of a product flavor and a build type). According to the official documentation (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的工作室 - 多个Android应用包含公共依赖于一个单一的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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