Android的图书​​馆项目采用了Android工作室 [英] Android Library Project using Android Studio

查看:136
本文介绍了Android的图书​​馆项目采用了Android工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能已经回答了什么地方也没有找到一个合适的。

This question might have been answered somewhere but couldn't find the appropriate one.

我想知道我怎么可以创建的Andr​​oid Studio中常见的实用工具库项目。 我想写一些常见的类和一些常用的方法,在他们的Andr​​oid应用项目中使用。也许喜欢.dll文件如何在Windows世界中 - 一组可在多个用户之间可以共享常用方法

I want to know how can I create a common utility library project in Android Studio. I want to write some common classes and some common methods within them to use in Android app projects. Probably like how .dll are in Windows world - a set of common methods that can be shared among multiple consumers.

在此先感谢。

推荐答案

最简单的做这样的:

  1. 右键点击您打开的项目在Android的工作室,并选择 最新及GT;模块

  1. Right click on your opened project in Android Studio and select New > Module

在左窗格中选择Android的图书​​馆,并点击下一步。

In the left Pane choose Android Library and click on next.

输入所有细节,勾去掉创建活动,主题和所有的如果不是必需的。

Enter all details, untick Create Activity, Theme and all if not required.

选择API级别相同的项目,下一步,下一步,下一步。

Choose API level same as your project and Next, Next, Next .

现在,您将看到您的项目中一个又一个目录, build.gradle 图书馆将自动为您配置。

Now you will see an another directory inside your project, build.gradle for library will be automatically configured for you.

如果你的模块/库的名称是MyLibrary的

If your module/library name is "mylibrary",

include ':mylibrary' 

将自动增加 settings.gradle 你的项目的根目录中的文件。

will be automatically added in settings.gradle file inside root directory of your project.

现在打开你的主模块和插入此行的从属模块:

Now open your main module and insert this line in dependency block :

compile project(':mylibrary')

如果你想使用同一个库在其他项目中,可以使用文件资源管理器将库模块复制到特定的项目和需要配置的 settings.gradle 并主模块的打造。摇篮手动。

If you want to use same library in other projects, you have to copy the library module to that particular project using File Explore and have to configure settings.gradle and main module's build.gradle manually.

这篇关于Android的图书​​馆项目采用了Android工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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