2

When using Mark Murphy's MergeAdapter everything compiles fine, but when the ListView binding occurs I get a crash with the following error when calling the addAdapter() method:

java.lang.NoClassDefFoundError: com.commonsware.cwac.sacklist.SackOfViewsAdapter

The SackOfViewsAdapter jar file does exist within libs dir of the cwac-merge project.

I have checked out the demo project that comes with the project and I can't see anything that it has that I don't, although I get NoClassDefFoundError exceptions when I try to run it.

I have a feeling this is an Eclipse configuration issue, but I have tried everything that I can think of.

Any ideas?

** Update: the SackOfViewsAdapter also shows up as a referenced library in the cwac-merge project.

** Update 2: My .classpath:

<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="lib" path="/Users/colsen/Projects/android/cwac-merge/libs/CWAC-SackOfViewsAdapter.jar"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

** Update 3 - copied SackOfViewsAdapter to local libs dir.

<classpath>
    <classpathentry kind="lib" path="libs/CWAC-SackOfViewsAdapter.jar"/>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
chris
  • 4,332
  • 5
  • 41
  • 61

1 Answers1

2

The SackOfViewsAdapter jar file does exist within libs dir of the cwac-merge project.

It looks like you need to also add SackOfViewsAdapter.jar to your Eclipse build path of the project using MergeAdapter. Even though the library project's reference to this works at compile time, it will not work at runtime.

I just updated the demo/ Eclipse project files to reflect this.

My apologies for the difficulty.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Hey Mark, I did previously try to reference the jar file directly from my project, but still couldn't get it to work. I updated the question to show my .classpath file which seems to match your on the commit you just made. https://github.com/commonsguy/cwac-merge/commit/d93d797eafae347e12714a25224b02ec96c687e7 – chris Feb 15 '12 at 20:29
  • @chris: Try copying the `SackOfViewsAdapter` JAR into your hosting project and adding it to your build path, instead of referencing the one from your `cwac-merge` directory. I also just realized that the error I was seeing was a bit different, complaining about missing `MergeAdapter$EnabledSackAdapter`. – CommonsWare Feb 15 '12 at 20:33
  • As shown in the .classpath above I tried moving the jar to the libs folder, but I still get the same error. I have also tried moving the merge.jar file to the libs dir as well, but it still fails (I then get a simular error but for the MergeAdapter jar file). I have also tried playing with the order of the libs in the include list, but I still get the same error. – chris Feb 15 '12 at 21:03
  • @chris: ::shrug:: You have me stumped. On a whim, try an Ant build. That has always worked (mostly because I wrote `MergeAdapter` before having my arm twisted to use Eclipse... :-) – CommonsWare Feb 15 '12 at 21:46
  • So what I forgot to mention was that I have one central *common* project that is being used by 2 different apps. I was copying the jar file to the common project and not the individual child projects. All is working now whether or not I reference the jar file within the cwac-merge project or the local one. Thanks for the help Mark. – chris Feb 15 '12 at 21:49