Library Project in Android Studio

若如初见. 提交于 2020-01-23 02:46:10

问题


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. Create a normal Android Project without an Activity
  2. Change apply plugin: 'com.android.application' to apply plugin: 'com.android.library' from build.gradle
  3. Delete the line applicationId "..." from build.gradle

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

  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

回答1:


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.



来源:https://stackoverflow.com/questions/27380270/library-project-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!