Saturday, 23 May 2015

Knowing gradle dependency jars download location and copying them to custom location


Whenever you need any dependency in your gradle script, gradle will download it it's cache and use it. By default you should see this cache in .gradle folder under your user directory.

For me it is
  • C:\Users\athakur\.gradle\caches
In this post I will show
  1. how to pinpoint exact location of the downloaded dependency jars and
  2. how to copy these jars to some custom directory you might want the dependencies in
using simple gradle scripts.

Gradle script to show downloaded jars location

Note : Whenever you execute some gradle task using gradle taskName then gradle will by default try finding the task in a file named build.gradle in current directory. 

Put the following code in build.gradle file - 

apply plugin: 'java'


  compile ''

task showMeCache << {
  configurations.compile.each { println it }

and run the following command
  • gradle showMeCache
You should see the downloaded jar location printed on console. For me it shows as in following screenshot

 Now let's see how we can copy these jar's into some custom directory of your choice.

Gradle script to copy downloaded jars to custom location

 Again append the following code to build.gradle file we created while printing the downloaded jar files location.

task copyDepJars(type: Copy) {
  from configurations.compile
  into 'C:\\Users\\athakur\\Desktop\\lib'

Now run following command
  • gradle copyDepJars
All dependent jars should be downloaded to the directory you have specified in "into" attribute of task copyDepJars .

To know more about copy task in gradle refer - Copy - Gradle DSL Version 2.4

Related Links

How to add autocomplete to EditText in Android - AutoCompleteTextView


Everyone must have used EditText to allow use input some text. Ever wondered if such a basic functionality could support autocomplete? Of course it would, it is one of the basic use cases. We will see how to implement it in this post.


AutoCompleteTextView is a direct subclass of EditText. We can use this to achieve auto complete feature in Android.

Let's start with the layout. I am going to keep it fairly simple. Just a label denoting what the following text field is for. In this case it would be list of countries. So we are going to provide auto complete for list of countries.

<RelativeLayout xmlns:android=""
    tools:context="${relativePackage}.${activityClass}" >



Layout would look something like

 Before we proceed to the Java code/Activity lets quickly define list of countries as string array in string resource file.

<?xml version="1.0" encoding="utf-8"?>

    <string name="app_name">AutocompleteDemo</string>
    <string name="title_activity_main">Auto Complete Demo</string>
    <string name="autocomplete_label">List of Countries</string>

    <string-array name="list_of_countries">


Have listed some random country name. That should suffice for this demo. Now lets code the Activity class.

package com.osfg.autocompletedemo;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

 * @author athakur
public class MainActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        AutoCompleteTextView acTextView = (AutoCompleteTextView) findViewById(;
        String[] countriesList = getResources().getStringArray(R.array.list_of_countries);
        ArrayAdapter countryAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,countriesList);

And that is it. You should be able to see auto complete now.

Related Links

t> UA-39527780-1 back to top