Android的工作室Java库模块与Android的库模块 [英] Android Studio Java Library Module vs. Android Library Module

查看:199
本文介绍了Android的工作室Java库模块与Android的库模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的期望的最终结果是,具有可以输出不同的productflavors手机,电视的,磨损的应用程序,共享相同的code-基地项目。所以我想在codeBase类是一个依赖于所有三种应用类型,其中每个应用程序模块将只包含活动和互动与codeBase的。

My desired end result is to have a Project that can output different productflavors of Mobile, Tv, and Wear apps, that share the same code-base. So I would like the codebase to be a dependency for all three app-types, where each app module would only contain activities and interaction with the codebase.

我的第一个想法是添加一个机器人库模块我的新创建的项目,但我注意到,这实际上就是利用自己的资源和一切新的应用模块。我想codeBase的功能更像是一个Java库,但它需要像android.graphics.Color包访问。

My first idea was to add a "Android Library Module" to my newly created project, but I noticed that this is really just a new app module with its own resources and everything. I would like the codebase to function more like a "Java Library", but it needs access to packages like "android.graphics.Color".

因此​​,简而言之,是实现这一结果使用Java库,引用了一个Android SDK的正确方法还是我只是要对这个错误的方式?

So in short, is the correct way of achieving this result to use a java library that has a reference to an android sdk or am i just going about this the wrong way?

延续了这一问题:<一href="http://stackoverflow.com/questions/28157981/does-an-android-library-need-a-manifest-app-name-icon">Does一个Android库需要一个清单,APP_NAME,图标?

推荐答案

有没有在两者之间。如果你想获得到Android的API,那么图书馆必须是一个Android库,以便构建系统可以正常到相关的项目联系起来。这是真的,Android的图书​​馆拥有资源,你可能不需要其他的东西,但你可以忽略这些位,如果你想基本上是把它当作一个普通的Java库。即使你不使用的资源,你可能会发现有用的Andr​​oidManifest.xml中指定属性被合并到相关的应用程序的能力。

There's no in-between. If you want access to Android APIs, then the library needs to be an Android library so that the build system can properly link it in to dependent projects. It's true that Android Libraries have resources and other things you may not need, but you can ignore those bits and treat it essentially as a plain Java library if you wish. Even if you're not using resources, you may find useful the ability to specify AndroidManifest.xml attributes to be merged into the dependent app.

Android的库项目不建立一个完全成熟的APK作为其输出;它产生的AAR,这在概念上类似于一个JAR档案,但资源和元信息有用到Android项目。

The Android Library project doesn't build a fully-fledged APK as its output; it generates an AAR, which is conceptually similar to a JAR archive, but has resources and meta-information useful to Android projects.

这篇关于Android的工作室Java库模块与Android的库模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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