June 16, 2014

Using Third party Library in your Android project

Things to know:

  • You can create Android library projects, which you can reference in other Android projects. Library projects cannot be installed onto a device. They are pulled into the APK file at build time.
  • The Android Support Library package is a set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs. Because of the library support your applications can use advanced libraries' features and still be compatible with devices running Android 1.6 (API level 4) and up.
Procedure:
1.  To create a Android Library Project , click New > 'Android Application Project'. Check 'Mark this project as a library' and uncheck 'Create custom...icon' & 'Create activity' as shown below.


























2. Am just reusing the Timber class from JakeWharton for this example. Now this will be the reusable library I'll be using throughout my Android projects.















3. Now open your existing project or create a new project. Shown below is the Android Support Library , TimberLoggerLibrary and the Android project TimberLoggerUser in which I'll be using the TimberLoggerLibrary





     
       When you create a new project you might see Android Support Libraries automatically linked by eclipse to provide backward compatibility. I am mentioning this here just for you to witness the use of android support libraries.





4. Right click on your Android project > properties. Click 'Android' tab on the left as choose the library by clicking 'Add'. Click 'Apply' > 'ok'





















5. At this point you have successfully linked the library project to your Android project and is ready to be reused. Below you can see that 'timberloggerlibrary.jar' is automatically added under Android Dependencies


No comments:

Post a Comment