Android Studio中的图书馆项目 [英] Library Project in Android Studio

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

问题描述

我刚刚安装了Android Studio,想知道如何创建一个Android Library项目.在中共享的解决方案这篇帖子不再有效.

I just installed Android Studio and wondering how I could create an Android Library project. The solution shared in this post does not work anymore.

更新:我不确定这是否足以创建一个库项目,但这是我已经完成的步骤:

Update: I am not sure if this is enough to create a library project, but this are the steps I have done:

  1. 创建没有活动的普通Android项目
  2. apply plugin: 'com.android.application' build.gradle
  3. 更改为apply plugin: 'com.android.library'
  4. build.gradle
  5. 中删除行applicationId "..."

如果您想将库创建为应用程序项目的一部分,则可以基于这篇文章:

If you would like to create a library as part of an application project, you could follow these steps based on this post:

  1. 转到文件> 新建> 新模块
  2. 在显示的创建新模块窗口中,单击 Android库
  3. 点击下一步
  4. 选择名称和最低SDK
  5. 点击完成
  1. Go to File > New > New Module
  2. In the Create New Module window that appears, click Android Library
  3. Click Next
  4. Select a name and minimum SDK
  5. Click Finish

推荐答案

相应地文档中没有" Library 项目"或" Application 项目"之类的东西.有一个"Android项目",其中包含 modules ,这些模块可以是 application 模块, library 模块, test 模块等.
我建议您从包含一个库模块的项目开始.如果以后发现需要添加一些测试,则将测试模块添加到该项目中.您有一天(也许)将其添加到库中的示例应用程序也是如此.
但是,如果由于某种原因要创建一个无任何项目的普通库模块,则可以按照答案中所述的三个步骤进行操作.恐怕没有底层Android项目,就没有内置的模块创建支持.

Accordingly to this document there is no such thing like 'Library project' or 'Application project'. There is 'Android project', which contains modules, and these can be application modules, library modules, test modules and so on.
I suggest you start with the project which consists of one library module. If later you'll find out that you need to add some tests, you'll add test module to this project. The same goes for the sample app which you'll someday (maybe) add to your library.
But, if for some reason you want to create plain library module, w/o any project, you can go with these three steps you described in your answer. I'm afraid there is no built-in support for creation of modules without underlying Android project.

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

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