android - 手机和平板电脑模块与 Android 库

标签 android android-library android-module

我想制作一个单独的模块,以便在项目之间共享它。该模块将具有 android 组件。因此,在创建新模块时,选项是手机和平板电脑模块和 Android 库。我想知道两者之间有什么区别。谢谢

最佳答案

什么是模块?来自Add a Module for a New Device documentation :

Modules provide a container for your app's source code, resource files, and app level settings, such as the module-level build file and Android manifest file. Each module can be independently built, tested, and debugged.

什么是 Android 库?来自 Create an Android Library documentation :

An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module. Unlike JAR files, AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.

您不能从一个模块访问组件到另一个模块。 所以,如果你需要在项目之间共享组件,你需要创建 Android 库。但请记住,您不能运行库。您只能从模块访问和使用它。此外,您可以使用 Gradle Android Maven plugin在本地安装您的库。

关于android - 手机和平板电脑模块与 Android 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45949294/

相关文章:

android - 无法从另一个模块 : Android studio 调用方法

android - 是否有一张表格说明在哪个版本中引入了 Android API 的哪些部分?

android - 如何在Android Studio中找到gradle插件的所有可用属性和方法?

java - 从 libgdx 中的核心模块类访问 Android 模块类

android - 无法从 XML 中的 AAR 中找到资源标识符

android - 带 map 和路线的 Android 项目要使用哪些库?

java - Gradle Android "Duplicate class foo found in module bar"错误

android - 如何在 Android 中为布局 (RelativeLayout) 设置图像边框?

android - 您可以将本地 html 资源加载到 WebView 中吗?

android - 如何使用模块创建库?