Android library projects provide reusable code and resources that can save you time and effort when developing apps — you don’t have to keep “reinventing the wheel.”

Android project can use code contained in JAR files (Java libraries). It is also possible to create libraries modules which can be used as dependencies in Android projects. These modules allow you to store source code and Android resources which can be shared between several other Android projects.

Here I am creating sample of libraries with access it in another application.

1.     Create an android project for library 
2.     Click Next and Mark this project as library


3.     Add class in Library

public class MyDemo {
     public String getMyResult() {
           return "Android Library Application......!";

4.      Create a new Android Project

5.      Add library in this project , use some following steps-:

·     Right click in your project and choose Properties  as given below

·         Now open a window choose Android as given below

·      Press add button and choose your library then click ok

After click ok press Apply button.



Now you have imported library in your application project. 

6.      Add following code in MainActivity.class


package com.example.androiddemolibrary; 
import com.example.mylibrary.MyDemo; 
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {     TextView textView;
     protected void onCreate(Bundle savedInstanceState) {
           textView = (TextView) findViewById(;
           // Call constructor of library class
           MyDemo demo = new MyDemo();
           // call method of library class  String text = demo.getMyResult();
     public boolean onCreateOptionsMenu(Menu menu) {
           // Inflate the menu; this adds items to the action bar if  it is present.
           getMenuInflater().inflate(, menu);
           return true;


Now run your application 

  Modified On Dec-02-2017 12:00:55 AM

Leave Comment