Android Shortcuts: Starting a new project

noras noras |

Tags: #Android #Android Studio #gradle #shortcuts

So you are staring your android project and need to prepare your gradle file. Here is a shortcut offered to you on a gold plate.

Adding the essential repositories

Android studio with gradle is an awesome framework that offers you a painless way to add libraries to your projects without any hassle. In order to import the libraries, they need to be imported from repositories. The most used libraries in my experience are the following.

repositories {
    maven { url '' }
    maven { url '' }
    maven { url '' }

Some of the most used libraries

Here is a list of the most used libraries by me. I will try to extend this list and add more explanations about how and when to use each library. Hopefully with some lovely shortcut code.

HTTP requests

 compile ''

Useful template for volley

 public class APIManager {

        private Cache cache;
        private Network network;
        private RequestQueue queue;
        private Context context;

        public APIManager(Context context) {
            this.context = context;
            cache = new DiskBasedCache(context.getCacheDir(), 1024 * 1024);
            network = new BasicNetwork(new HurlStack());
            queue = new RequestQueue(cache, network);

        public void doSomePostRequest(String payload) {

            final JSONObject params = new JSONObject();
            try {

                JSONObject payloadJson = new JSONObject();
                payloadJson.put("payload", payload);

            } catch (JSONException e) {

            JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, API_ENDPOINT, params,
                    new Response.Listener<JSONObject>() {
                        public void onResponse(JSONObject response) {

                            Log.d("RESPONSE ", "RESPONSE " + response.toString());

                    }, new Response.ErrorListener() {
                    public void onErrorResponse(VolleyError error) {
                        Log.d("RESPONSE_ERROR", "RESPONSE_ERROR " + error.getMessage());
                        NetworkResponse networkResponse = error.networkResponse;
                        if (networkResponse != null && != null) {
                            String jsonError = new String(;
                            // Print Error!
                            Log.d("RESPONSE_ERROR", "RESPONSE_ERROR " + jsonError);




Loading spinners


 compile 'com.github.ybq:Android-SpinKit:1.2.0'

Chart library


 compile 'com.github.PhilJay:MPAndroidChart:v3.0.3'

Customisable button navigation bar

compile 'com.aurelhubert:ahbottomnavigation:2.1.0'


compile ''

View Pager Indicator

compile ''

Barcode and Qr-code scanning

 compile 'me.dm7.barcodescanner:zbar:1.9'

Loading and caching images

 compile 'com.squareup.picasso:picasso:2.5.2'

Tracking crashes

compile('') {
        transitive = true;

Binding JSON to Objects

 compile 'com.fasterxml.jackson.core:jackson-core:2.6.7'
 compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.7'
 compile 'com.fasterxml.jackson.core:jackson-databind:2.6.7'

Local database solution

 compile 'com.j256.ormlite:ormlite-android:4.48'

Internal data exchange

 compile 'de.greenrobot:eventbus:2.2.1'

Scanning credit cards

compile 'io.card:android-sdk:5.5.0'

About the author


"Senior Software Engineer. MSc in Computer systems and Networks with big interest in security. Loves to play with Android code and does security research for fun and profit. Speaks 4 languages and codes in much more."

Related articles

Tags: #Android #Android Studio #gradle #shortcuts

Copyright © 2020 -