Android

Android ListFragment conflicts with a type defined in the same file – Heights of Ignorance

Posted on Updated on

Yesterday I stumbled upon below error while developing my Android application which also has a ListFragment

The import android.support.v4.app.ListFragment conflicts with a type defined in the same file

I had android-support-v4.jar in my libs folder and I was finding it
very difficult to understand what could go wrong in such a simple class.

And after taking a closer look it was heights of ignorance :),
see my class definition below:

import android.support.v4.app.ListFragment;

public class ListFragment extends ListFragment {

}

I had given my class name as ListFragment,
and compiler was correctly telling me what went wrong.

Android unable to execute dex : multiple dex files define Landroid

Posted on Updated on

Just today I started getting this exception:

unable to execute dex : multiple dex files define Landroid

Cause: This exception will come if you have multiple version of support library.

Where to check:

  1. Right Click on Project and select Build Path
  2. Check in Libraries if you have support library added (This happens when we do Android Tools -> Fix Project Properties)
  3. If you don’t find any such instance then check if you have copied support library manually into the lib folder of your project
  4. If you don’t find any such duplicates then check how many Android libraries (custom applications like FacebookSDK) 

Remove the duplicate libraries and do a clean -> rebuild

Hope this helps.

Android : Class file collision: A resource exists with a different case:

Posted on Updated on

Today I started getting this weird message in my Android project.

A resource exists with a different case: ‘/MyApp/bin/classes/com/mumz/R$Id.class’.

Initially I didn’t look at the error message closely and was goggling to get a resolution, which unfortunately I didn’t find so I came back to my eclipse and looked closely to the message. It was saying Id.class exists with different case, and then I found I already have a class with name as Id.

To fix all I had to do was to search my project for any occurrence of Id instead of id and I found that in my menu.xml, changed the case and that’s it my issue was resolved.

I have also posted this on Stackoverflow