我收到此错误
“无法访问超级类型的'android.support.v4.app.Fragment' “ com.google.android.youtube.player.YouTubePlayerSupportFragment”。 检查您的模块类路径是否缺少依赖项或发生冲突”
但是我正确地实现了有关youtube播放器API的所有功能
private fun initializeYoutubePlayer() {
youTubePlayerFragment = supportFragmentManager
.findFragmentById(R.id.youtube_player_fragment) as YouTubePlayerSupportFragment
if (youTubePlayerFragment === null)
return;
youTubePlayerFragment!!.initialize(
Constants.DEVELOPER_KEY,
object : YouTubePlayer.OnInitializedListener {
override fun onInitializationSuccess(
provider: YouTubePlayer.Provider, player: YouTubePlayer,
wasRestored: Boolean
) {
if (!wasRestored) {
youTubePlayer = player
//set the player style default
youTubePlayer!!.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT)
// youTubePlayer!!.cueVideo("lwg-k9_PAdM")
//cue the 1st video by default
youTubePlayer!!.cueVideo(youtubeVideoArrayList?.get(0)?.videoID)
}
}
override fun onInitializationFailure(
arg0: YouTubePlayer.Provider,
arg1: YouTubeInitializationResult
) {
//print or show error if initialization failed
Log.e(TAG, "Youtube Player View initialization failed")
}
})
}