Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert an android project into a library project in Eclipse?

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.

like image 381
user1844638 Avatar asked Jan 30 '13 06:01

user1844638


People also ask

How do I create a library for Android?

Creating The Android Library Open Android Studio and create a new Project. Name your application as ToasterExample and your project name as Toaster. The ToasterExample will be our sample application to show an example use of our application. Click on Finish and your project will be ready.

How do I copy an Android project?

Select your project then go to Refactor -> Copy... . Android Studio will ask you the new name and where you want to copy the project. Provide the same. After the copying is done, open your new project in Android Studio.

Can I import an android studio project?

Launch Android Studio, and click File > New > Import Project. Locate your project directory, click the build. gradle file you created above to select it, and then click OK to import your project.


2 Answers

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.

like image 147
Pankaj Kumar Avatar answered Sep 21 '22 23:09

Pankaj Kumar


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.

like image 39
Shadow Avatar answered Sep 17 '22 23:09

Shadow