2

我正在尝试使我的应用程序向后兼容 Android 2.2。

我有 Fragments、ListFragments、FragmentPagerAdapter 和 ActionBarSherlock 都在发生。

我已经包含了 android 支持库,并且构建在我的 android 4.1 设备上完美运行,但在 2.2 设备上,我得到以下内容:

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;

我已经玩了几个小时了,但我只是不知道该尝试什么。任何建议表示赞赏。如果您需要查看一些代码,请告诉我。

谢谢。

4

1 回答 1

1

在阅读了我自己的 SO 问题后,我意识到我并没有正确地解释以下内容:

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

ActionBarSherlock 似乎不支持 onQueryTextListener 和其他一些元素。反正我也不需要这些方法,所以我把它们从活动中去掉,问题就解决了。

我想onQueryTextChange在4.1设备上是原生支持的,但在2.2设备上(actionBar由ActionBarsherlock支持),这些方法是不支持的。

于 2012-09-24T03:42:58.907 回答