Android Studio 中的库项目 [英] Library Project in Android Studio

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

问题描述

我刚刚安装了 Android Studio,想知道如何创建一个 Android 库项目.中分享的解决方案这个帖子已经失效了.

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. 创建一个没有 Activity 的普通 Android 项目
  2. apply plugin: 'com.android.application'build.gradle 更改为 apply plugin: 'com.android.library'
  3. build.gradle
  4. 中删除行 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

推荐答案

根据this 文档中没有Library 项目"或应用程序 项目"之类的东西.有Android 项目",它包含模块,这些可以是应用程序 模块、 模块、测试模块等.
我建议您从包含一个库模块的项目开始.如果稍后您发现需要添加一些测试,则将测试模块添加到该项目中.示例应用程序也是如此,您有一天(可能)将其添加到您的库中.
但是,如果由于某种原因您想创建没有任何项目的普通库模块,您可以按照您在答案中描述的这三个步骤进行.恐怕没有内置支持创建没有底层 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天全站免登陆