2013-11-26 40 views
0
11-26 15:50:58.159: E/AndroidRuntime(3199): java.lang.NoClassDefFoundError: com.android.PlayMedia 
11-26 15:50:58.159: E/AndroidRuntime(3199):  at com.android.Description.onClick(Description.java:63) 

行號63java.lang.NoClassDefFoundError:同時使用YouTube API

startActivity(new Intent(Description.this,PlayMedia.class)); 

PlayMedia.java

public class PlayMedia extends YouTubeFailureRecoveryActivity{ 
public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.play_media); 

     YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view); 
     youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, this); 



} 
@Override 
    public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, 
      boolean wasRestored) { 
     if (!wasRestored) { 
      player.cueVideo("wKJ9KzGQq0w"); 
     } 
    } 

    @Override 
    protected YouTubePlayer.Provider getYouTubePlayerProvider() { 
     return (YouTubePlayerView) findViewById(R.id.youtube_view); 
    } 
} 

YouTubeFailureRecoveryActivity.java

(由YouTube本身提供)
public abstract class YouTubeFailureRecoveryActivity extends YouTubeBaseActivity implements 
    YouTubePlayer.OnInitializedListener { 

    private static final int RECOVERY_DIALOG_REQUEST = 1; 

    @Override 
    public void onInitializationFailure(YouTubePlayer.Provider provider, 
     YouTubeInitializationResult errorReason) { 
    if (errorReason.isUserRecoverableError()) { 
     errorReason.getErrorDialog(this, RECOVERY_DIALOG_REQUEST).show(); 
    } else { 
     String errorMessage = String.format(getString(R.string.error_player), errorReason.toString()); 
     Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show(); 
    } 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == RECOVERY_DIALOG_REQUEST) { 
     // Retry initialization if user performed a recovery action 
     getYouTubePlayerProvider().initialize(DeveloperKey.DEVELOPER_KEY, this); 
    } 
    } 

    protected abstract YouTubePlayer.Provider getYouTubePlayerProvider(); 

} 

我已在我的Manifest文件中註冊了活動PlayMedia

回答

1

試試這個:

轉到項目/屬性/ Java構建路徑/訂單和出口 - 確保有一個在Android的依賴關係的正面和支持庫進行檢查,如果使用it.Mark所有複選框。點擊Apply並清理項目。

這爲我工作。希望這會有所幫助。

+0

我已經試過了,它沒有幫助 – onkar

+0

您是否使用任何外部罐子? –

+0

是的,重新啓動了日食並重試了這些步驟,結果奏效了。 – onkar