Android – How to clean Android Studio project from libraries

When there is a need to upload or send Android Studio project as zip archive, it takes significant amount of space. But there is a solution for this problem. Open terminal on Android Studio and enter:

./gradlew clean

After cleaning project takes much less space and it is convenient to send as zip archive.

Android – Warning:Conflict with dependency ‘’ solution

When I tried to add these library dependencies:

    compile 'com.trello:rxlifecycle:0.7.0'
    compile 'com.trello:rxlifecycle-android:0.7.0'

I received following error:

Warning:Conflict with dependency ‘’. Resolved versions for app (3.0.1) and test app (2.0.1) differ. See for details.
Error:Execution failed for task ‘:app:prepareDebugAndroidTestDependencies’.
> Dependency Error. See console for details.
Information:BUILD FAILED

Then I googled and found this solution:
In your apps build.gradle add the following within android { }:

configurations.all {
    resolutionStrategy.force ''

How to use lambda in Android Studio?

First of all, add following to build.gradle(app) file:

android {
    defaultConfig {
        jackOptions {
            enabled true
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8

After that you can use lambda in your application:

        Button button = (Button) findViewById(;
        button.setOnClickListener(v-> Toast.makeText(getApplicationContext(), "Hello Lambda", Toast.LENGTH_LONG).show());

instead of this:

        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Toast.makeText(getApplicationContext(), "Hello Lambda", Toast.LENGTH_LONG).show();

Android – RecyclerView adapter example

public class PeopleAdapter extends RecyclerView.Adapter<PeopleAdapter.ViewHolder> {

    List<Person> people;

    public PeopleAdapter(List<Person> people) {
        this.people = people;

    public PeopleAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listitem_person, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;

    public static class ViewHolder extends RecyclerView.ViewHolder {

        TextView name;
        TextView number;

        ViewHolder(View itemView) {
            name = (TextView) itemView.findViewById(;
            number = (TextView) itemView.findViewById(;

    public void onBindViewHolder(ViewHolder holder, int position) {
        Person person = people.get(position);;

    public int getItemCount() {
        return people.size();


Android – what is android:supportsRtl=”true” for?


I always thought what is this for? Now I found what for. It is for supporting Arabic, Urdu, Hebrew languages. Because those languages are written from right to left. If you set supportsRtl true, your layout will be mirrored from right to left. So you do not have to create special layout for it. If you set false, your layout remain same no matter what language is used.

This is supported from API 17 – Android 4.2.

Android – How to load NavigationView menu item icon from URL using Picasso

    // this set prevents collecting targets by garbage collector
    final Set<Target> targets = new HashSet<>();

    private void loadMenuIcon(final MenuItem menuItem, String url) {

        Target target = new Target() {
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
                BitmapDrawable mBitmapDrawable = new BitmapDrawable(getResources(), bitmap);

            public void onBitmapFailed(Drawable drawable) {}

            public void onPrepareLoad(Drawable drawable) {}





            Menu menu = navigationView.getMenu();
            MenuItem item = menu.add(0, id, i, name);
            loadMenuIcon(item, url);