如何在android studio中创建库(jar)? [英] how to create library ( jar ) in android studio ?

查看:95
本文介绍了如何在android studio中创建库(jar)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一些库,将来将在当前项目旁边使用.

I want to create some library that i will use in the future beside my current project.

我找不到在android studio中创建库的方法.

I can't find a way to create library in android studio.

如何在android上执行此操作?

How to do it on android ?

推荐答案

库模块在以下情况下很有用: 当您构建使用某些相同组件(例如活动,服务或UI布局)的多个应用程序时. 当您构建包含多个APK变体的应用程序(例如免费和付费版本)时,两者都需要相同的核心组件. 无论哪种情况,只需将要重用的文件移动到库模块中,然后将库添加为每个应用程序模块的依赖项. 要在您的项目中创建一个新的库模块,请按照下列步骤操作:

A library module is useful in the following situations: When you're building multiple apps that use some of the same components, such as activities, services, or UI layouts. When you're building an app that exists in multiple APK variations, such as a free and paid version and you need the same core components in both. In either case, simply move the files you want to reuse into a library module then add the library as a dependency for each app module. To create a new library module in your project, proceed as follows:

点击文件>新建>新建模块.

Click File > New > New Module.

在出现的创建新模块"窗口中,单击"Android库",然后单击下一步".

In the Create New Module window that appears, click Android Library, then click Next.

还有一个创建Java库的选项,该库将构建传统的JAR文件.

There's also an option to create a Java Library, which builds a traditional JAR file.

为您的库命名,并为库中的代码选择一个最低的SDK版本,然后单击完成".

Give your library a name and select a minimum SDK version for the code in the library, then click Finish.

Gradle项目同步完成后,库模块将出现在左侧的项目"面板中.

Once the Gradle project sync completes, the library module appears in the Project panel on the left.

如果您没有看到新的模块文件夹,请确保它显示的是Android视图.

If you don't see the new module folder, make sure it's displaying the Android view.

访问 https://developer.android.com/studio/projects/android-library.html

这篇关于如何在android studio中创建库(jar)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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