我想制作一个单独的模块,以便在项目之间共享它。该模块将具有 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/