ActionBarSherlock - The type android.support.v4.app.Fragment cannot be resolved. It is indirectly referenced from required .class files

znat picture znat · May 16, 2013 · Viewed 54.4k times · Source

I am using ActionBarSherlock as a library project in a project which is a library itself. It was all working fine until I moved the project to a new computer and updated the SDK tools.

I have this error I don't understand. When I create a class extending SherlockFragment like this:

import com.actionbarsherlock.app.SherlockFragment;

public class SomeFragment extends SherlockFragment {
    ... 
}

I have the following compilation error:

The type android.support.v4.app.Fragment cannot be resolved. It is indirectly referenced from required .class files

I have checked the following:

  • ActionBarSherlock is imported as a library
  • No apparent errors in build path (no red cross) and actionbarsherlock.jar is present
  • The support library is in the ActionBarSherlock project and NOT in other depending projects

Anything else?

Answer

Sébastien BATEZAT picture Sébastien BATEZAT · May 16, 2013

I had the same problem as you since I had updated the SDK. I have solved my problem by doing this (on eclipse) :

  • Right click on the action bar sherlock library => Properties => Java Build Path => Order and Export tab => check android support v4 or Android Private Libraries and select Ok
  • Right click on your personal project and go to properties => java build path => check Android Private Libraries
  • Clean both projects, it should work.