Question

I have a class that extends android.support.v4.PreferenceFragment. When I run the app I first get this warning on LogCat:

04-02 14:22:57.113: W/dalvikvm(28828): VFY: unable to resolve static field 656 (preference_list_fragment) in Landroid/support/v4/preferencefragment/R$layout;

Then upon tapping an option on the app's UI, it shuts down and this error appears on LogCat

04-02 14:22:57.158: E/AndroidRuntime(28828): FATAL EXCEPTION: main
04-02 14:22:57.158: E/AndroidRuntime(28828): java.lang.NoClassDefFoundError: android.support.v4.preferencefragment.R$layout
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.preference.PreferenceFragment.onCreateView(PreferenceFragment.java:95)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.os.Handler.handleCallback(Handler.java:725)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.os.Looper.loop(Looper.java:137)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at android.app.ActivityThread.main(ActivityThread.java:5039)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at java.lang.reflect.Method.invokeNative(Native Method)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at java.lang.reflect.Method.invoke(Method.java:511)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-02 14:22:57.158: E/AndroidRuntime(28828):    at dalvik.system.NativeStart.main(Native Method)

I have gone through many posts about the same problem, and I did all of the following already:

  • Downloaded PreferenceFragment from https://github.com/kolavar/android-support-v4-preferencefragment, imported it as a project, and added it as a required project to my buildpath.
  • Tried that last step with the code from https://github.com/escrichov/guide/tree/master/android-support-v4-preferencefragment-master as well
  • Added android-support-v4.jar in the libs folder, and added it to my build path
  • Added android-support-v4-preferencefragment-master.jar in the libs folder, and added it to my build path
  • Checked the android-support-v4-prerferencefragment in the Order and Export tab of Java Build Path
  • Tried right clicking my project-> Android tools -> Add support library
  • Cleaned the project after each of those changes
  • Downloaded Android Support Library and Android Support Repository from the Android SDK Manager.

But still the problem persists.

I am testing on a nexus 10

Was it helpful?

Solution

Generally speaking, never mess with the build path manually.

The project you are trying to use is an Android library project. There are instructions for adding a dependency on an Android library project to your Eclipse project. Given that you have imported it into your Eclipse workspace, you need to add it as a dependency via the Android portion of your project settings:

Android Project Properties

Click the Add button, choose this library project from the dialog, click OK to close up each dialog, and you should be set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top