How to convert an android project into a library p

2019-01-18 15:43发布

问题:

I want to convert an android project into a library project. Can this be done?

I am trying to use this project in another project.

回答1:

Update for Android Studio option

Convert an app module to a library module

If you have an existing app module with all the code you want to reuse, you can turn it into a library module as follows:

  1. Open the build.gradle file for the existing app module. At the top, you should see the following:

    apply plugin: 'com.android.application'

  2. Change the plugin assignment as shown here:

    apply plugin: 'com.android.library'

  3. Click Sync Project with Gradle Files.

That's it. The entire structure of the module remains the same, but it now operates as an Android library and the build will now create an AAR file instead of an APK

Read more about how to Create an Android Library and how to Convert existing project to library project in Android Studio


Below steps are for Eclipse

Steps are

Right click on project -> property -> Android -> check 'Is library' check box -> OK

That's it.



回答2:

S.It's possible. For eg: if you take Actionbar sherlock.

https://github.com/JakeWharton/ActionBarSherlock/tree/master/library, it's a library

that has been created . You can import that in properties->Android->library.



回答3:

Or if you are using a Mac;

Step One. Hold down ctrl and tap on the project. Step Two. Click Property Step Three, Android Step Four, ensure the "Is Library" check box is ticked.