2012-09-20 48 views
2

我想讓我的應用向後兼容到Android 2.2。運行在2.2錯誤的片段 - 找不到類

我已經有碎片,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; 

我一直在玩弄這幾個小時,但我只是不知道該怎麼嘗試。任何建議表示讚賞。如果您需要查看一些代碼,請告訴我。

謝謝。

+0

如果沒有看到代碼,我們所能做的只是猜測......您是使用'getSupportFragmentManager'還是'getFragmentManager'?對於使用支持庫,您應該使用前者...以及「FragmentActivity」而不是簡單的「Activity」。 – Barak

+0

我正在使用getSupportFragmentManager。 我很抱歉在所有這段時間試圖解決這個問題後,在這裏查看堆棧跟蹤給了我一些額外的提示 - 我剛剛解決了這個問題..我非常確定ActionBarSherlock不支持SearchView $ OnQueryTextListener,所以我把它拿出來,現在它工作正常。我明天會給出正確的答案 - 我必須睡覺! –

回答

1

我讀我自己的SO問題後意識到,我並沒有解釋corrsctly如下:

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

看來,ActionBarSherlock不支持onQueryTextListener,以及其他一些因素。無論如何,我並不需要這些方法,所以我將它們從禮拜中刪除,問題就解決了。

我想在4.1設備本身支持onQueryTextChange,但在2.2設備(ActionBar由ActionBarsherlock支持),這些方法不受支持。