Seven Android Libraries For Every Android Developer

Shared Hosting Email on Mobile
31 December 2016

Seven Android Library

Importing libraries makes works easier. We are using 7 libraries in every project we are doing now a days and we believe every developer should know about it. So Here is updated list on android libraries:-

All application are dynamic and JSON Api are backbone of every dynamic application. Gson is java library which does most of our work on serializing and deserializing java objects from and into JSON. We can include it in our project by simply adding following line to gradle dependencies.

compile ''

Example of GSON is as follows

User user = new User();

String json= new Gson().toJson(user);

User user = new Gson().fromJson(json_string,User.class);

2. Retrofit
Rest api are in trend now a days and whats better than a library which does all work for you . The relative url with method annotations makes your code neat. You can included retrofit in your project by just adding a line to your dependency.

compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'

Example of Retrofit is as follows

public interface GitHubClient {

         List <Contributor> contributors(
         @Path("owner") String owner,
         @Path("repo") String repo

static class Contributor{
     String login;
     int contributions;

public static void main(String... args) {
         // Create a very simple REST adapter which points the GitHub API endpoint.
         GitHubClient client = ServiceGenerator.createService(GitHubClient.class);

         // Fetch and print a list of the contributors to this library.
         Call<List<Contributor>> call =
         client.contributors("fs_opensource", "android-boilerplate");

         try {
         List <Contributor> contributors = call.execute().body();
         } catch (IOException e) {          // handle errors

         for (Contributor contributor : contributors) {
         contributor.login + " (" + contributor.contributions + ")");

3. Eventbus
Event Bus is a library to make connection between different parts of your application. Its an library which makes it easy to create custom events and listen to them. To include Eventbus in application we have to add this to your dependency.

compile 'de.greenrobot:eventbus:2.2.+'

Example of Event Bus is as follows

public class NetworkStateReceiver extends BroadcastReceiver {

// post event if there is no Internet connection
         public void onReceive(Context context, Intent intent) {
                  super.onReceive(context, intent);
                  if(intent.getExtras()!=null) {
                  NetworkInfo ni=(NetworkInfo)
                  if(ni!=null && ni.getState()==NetworkInfo.State.CONNECTED) {
                  // there is Internet connection
                  } else if(intent
                  .getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,Boolean.FALSE)) {
                  no Internet connection, send network state changed
                  EventBus.getDefault().post(new NetworkStateChanged(false));

public class NetworkStateChanged {

         private mIsInternetConnected;

         public NetworkStateChanged(boolean isInternetConnected) {
         this.mIsInternetConnected = isInternetConnected;

         public boolean isInternetConnected() {
         return this.mIsInternetConnected;
         //Add this to main activity
         // method that will be called when someone posts an event NetworkStateChanged
public void onEventMainThread(NetworkStateChanged event) {
         if (!event.isInternetConnected()) {
         Toast.makeText(this, "No Internet connection!", Toast.LENGTH_SHORT).show();

4. ButterKnife
Butterknife is a library which makes it very easy to connect layout files and activity without writing too much code. We can use Butter knife in our project by adding

compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'

Example of Butterknife

class ExampleActivity extends Activity {

  @BindView( TextView title;

    @Override public void onCreate(Bundle savedInstanceState) {
         // TODO Use fields...

its same like

class ExampleActivity extends Activity {

   TextView title;

    @Override public void onCreate(Bundle savedInstanceState) {
         // TODO Use fields...

5. Gilde
Gilde is an very easy asynchronous loading and caching image libray. We can use this in our project by adding following to gradle.

compile 'com.github.bumptech.glide:glide:3.7.0'

Example of Glide


6. Realm
Realm is out of box, opensource database for mobile platform. Its simple yet poweful database. You can manage very big data in seconds in realm. To include realm in your project we have to do following.

     ///project level gradle
   dependencies {
     classpath "io.realm:realm-gradle-plugin:2.2.1"
     ///apply plugin
   apply plugin: 'realm-android'

Example of realm

  public class Dog extends RealmObject {
     public String name;
    public int age;

//Adding Object Starts Here
   Dog dog = new Dog(); = "Rex";
   dog.age = 1;
  Realm realm = Realm.getDefaultInstance();
   //Ends Here

   //Finding Realm Object
   RealmResults<Dog> pups = realm.where(Dog.class)
   .lessThan("age", 2)

7. ReactiveLocation
Reactive location is a java library for getting locations.Small but very useful wrapper of the Google Play API to get the location We can include it in our project by adding in gradle.

compile ''
compile ''
compile ''
compile 'io.reactivex:rxjava:1.2.0'


        //Getting last known location
   ReactiveLocationProvider locationProvider = new ReactiveLocationProvider(context);
        .subscribe(new Action1<Location>() {
            public void call(Location location) {

By Lakshay Jain

Tags: Android, Email