YouTube API 在 android 中出现错误 RuntimeException

YouTube API getting error RuntimeException in android

我是 YouTube 的新手 API,我的 YouTube 视频是从我的服务器获取的,当我点击图像时出现错误请任何人帮助我解决这个问题

我的Logcat错误

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.worldrev.revapp/com.worldrev.revapp.model.PlayYouTube1st}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.youtube.api.service.START } at com.worldrev.revapp.model.PlayYouTube1st.onCreate(PlayYouTube1st.java:37)

当我点击 YouTube 图片时出现此错误,请任何人帮助解决此问题

这是我的代码

PlayYouTube1st.java

private static final int RECOVERY_DIALOG_REQUEST = 1;
String DEVELOPER_KEY = "AIzaSyAECWqrQPzIdsjdsdPtsaFr4ddada";
// YouTube player view
private YouTubePlayerView youTubeView;
String youtubeLink;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.youtube_main);
    Intent intent =getIntent();
    youtubeLink=intent.getStringExtra("youtubeLink");
    youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);

    // Initializing video player with developer key
    youTubeView.initialize(DEVELOPER_KEY, this);

}

@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
public void onInitializationSuccess(YouTubePlayer.Provider provider,
        YouTubePlayer player, boolean wasRestored) {
    if (!wasRestored) {

        // loadVideo() will auto play video
        // Use cueVideo() method, if you don't want to play it automatically
        player.loadVideo(youtubeLink);

        // Hiding player controls
        player.setPlayerStyle(PlayerStyle.CHROMELESS);
    }
}

@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(Config.DEVELOPER_KEY, this);
    }
}

private YouTubePlayer.Provider getYouTubePlayerProvider() {
    return (YouTubePlayerView) findViewById(R.id.youtube_view);
}

}

我的清单 ManifestXml.XMl

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".model.PlayYouTube1st"/>
    <activity
        android:name=".model.News_update_fulldecActivity"
        android:label="@string/title_activity_news_update_fulldec"
        android:theme="@style/AppTheme.NoActionBar" >
    </activity>
    <activity
        android:name=".Movie_rev_fulldis_activity"
        android:label="@string/title_activity_movie_rev_fulldis_activity"
        android:theme="@style/AppTheme.NoActionBar" >
    </activity>
</application>

这个问题出现在 Youtube API (1.2.1) version.so 更新最新版本 (1.2.2)。

下载最新版本YouTube Android Player API - Download

该问题fixed.No 隐式意图问题已在版本 1.2.2 中解决