2

I'm trying to make my app backwards compatible to Android 2.2.

I've got Fragments, ListFragments, a FragmentPagerAdapter, and ActionBarSherlock all happening.

I've got the android support library included, and the build works perfectly on my android 4.1 device, but on the 2.2 device, I get the following:

09-21 00:10:32.867: I/dalvikvm(1229): Failed resolving Lanother/music/player/AlbumListFragment; interface 521 'Landroid/widget/SearchView$OnQueryTextListener;'
09-21 00:10:32.877: W/dalvikvm(1229): Link of class 'Lanother/music/player/AlbumListFragment;' failed
09-21 00:10:32.877: E/dalvikvm(1229): Could not find class 'another.music.player.AlbumListFragment', referenced from method another.music.player.MainActivity.<init>
09-21 00:10:32.877: W/dalvikvm(1229): VFY: unable to resolve new-instance 531 (Lanother/music/player/AlbumListFragment;) in Lanother/music/player/MainActivity;
09-21 00:10:32.877: I/dalvikvm(1229): Could not find method another.music.player.MainActivity.getActionBar, referenced from method another.music.player.MainActivity.onCreate
09-21 00:10:32.887: W/dalvikvm(1229): VFY: unable to resolve virtual method 3906: Lanother/music/player/MainActivity;.getActionBar ()Landroid/app/ActionBar;
09-21 00:10:32.887: I/dalvikvm(1229): Failed resolving Lanother/music/player/AlbumListFragment; interface 521 'Landroid/widget/SearchView$OnQueryTextListener;'
09-21 00:10:32.887: W/dalvikvm(1229): Link of class 'Lanother/music/player/AlbumListFragment;' failed
09-21 00:10:32.887: E/dalvikvm(1229): Could not find class 'another.music.player.AlbumListFragment', referenced from method another.music.player.MainActivity.onListItemClicked
09-21 00:10:32.887: W/dalvikvm(1229): VFY: unable to resolve new-instance 531 (Lanother/music/player/AlbumListFragment;) in Lanother/music/player/MainActivity;
09-21 00:10:32.887: I/dalvikvm(1229): Failed resolving Lanother/music/player/SongListFragment; interface 521 'Landroid/widget/SearchView$OnQueryTextListener;'
09-21 00:10:32.887: W/dalvikvm(1229): Link of class 'Lanother/music/player/SongListFragment;' failed
09-21 00:10:32.887: E/dalvikvm(1229): Could not find class 'another.music.player.SongListFragment', referenced from method another.music.player.MainActivity.onListItemClicked
09-21 00:10:32.887: W/dalvikvm(1229): VFY: unable to resolve new-instance 576 (Lanother/music/player/SongListFragment;) in Lanother/music/player/MainActivity;
09-21 00:10:32.887: I/dalvikvm(1229): Could not find method another.music.player.MainActivity.getActionBar, referenced from method another.music.player.MainActivity.onOptionsItemSelected
09-21 00:10:32.887: W/dalvikvm(1229): VFY: unable to resolve virtual method 3906: Lanother/music/player/MainActivity;.getActionBar ()Landroid/app/ActionBar;
09-21 00:10:32.887: I/dalvikvm(1229): Failed resolving Lanother/music/player/AlbumListFragment; interface 521 'Landroid/widget/SearchView$OnQueryTextListener;'
09-21 00:10:32.887: W/dalvikvm(1229): Link of class 'Lanother/music/player/AlbumListFragment;' failed
09-21 00:10:32.887: E/dalvikvm(1229): Could not find class 'another.music.player.AlbumListFragment', referenced from method another.music.player.MainActivity.onOptionsItemSelected
09-21 00:10:32.887: W/dalvikvm(1229): VFY: unable to resolve new-instance 531 (Lanother/music/player/AlbumListFragment;) in Lanother/music/player/MainActivity;
09-21 00:10:32.897: I/dalvikvm(1229): Could not find method android.support.v4.app.FragmentActivity.getActionBar, referenced from method another.music.player.ArtistListFragment.onListItemClick
09-21 00:10:32.897: W/dalvikvm(1229): VFY: unable to resolve virtual method 810: Landroid/support/v4/app/FragmentActivity;.getActionBar ()Landroid/app/ActionBar;

I've been playing around with this for hours, but I just don't know what to try. Any suggestions are appreciated. If you need to see some code, just let me know.

Thanks.

Tim Malseed
  • 6,003
  • 6
  • 48
  • 66
  • Without seeing code, all we can do is guess... are you using `getSupportFragmentManager` or `getFragmentManager`? For using the support library you should be using the former... along with a `FragmentActivity` instead of a plain `Activity`. – Barak Sep 20 '12 at 14:35
  • I'm using getSupportFragmentManager. I'm sorry to say after all this time trying to work it out, looking at the stack trace here gave me a few extra hints - and I just solved the problem.. I'm pretty sure ActionBarSherlock doesn't support SearchView$OnQueryTextListener, so I took it out and it's working OK now. I'll put a proper answer up tomorrow-- I must sleep! – Tim Malseed Sep 20 '12 at 14:37

1 Answers1

1

I realised after reading my own SO question, that I wasn't interpreting the following corrsctly:

09-21 00:10:32.867: I/dalvikvm(1229): Failed resolving Lanother/music/player/AlbumListFragment; interface 521 'Landroid/widget/SearchView$OnQueryTextListener;

It seems that ActionBarSherlock doesn't support the onQueryTextListener, and some other elements. I didn't need these methods anyway, so I removed them from the ativity, and the problem was solved.

I imagine that onQueryTextChange is supported natively in the 4.1 device, but on the 2.2 device (where the actionBar is supported by ActionBarsherlock), these methods are not supported.

Tim Malseed
  • 6,003
  • 6
  • 48
  • 66