Library Project in Android Studio

2019-04-13 11:28发布

问题:

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.