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)

第 63 行

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

播放媒体.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();

}

我已经PlayMedia在我的Manifest文件中注册了该活动。

4

1 回答 1

1

试试这个:

转到 Project/Properties/Java Build Path/Order and Export -- 如果您使用它,请确保在 Android 依赖项和支持库前面有一个检查。标记所有复选框。单击应用并清理项目。

这对我有用。希望这会有所帮助。

于 2013-11-26T10:27:27.100 回答