我在Android中使用YouTube API,而我的Android版本是4.4.4并且效果很好,但(5.0 / 6.0 / 6.1 / 7.0 / 7.1)Android版本中的相同应用无效。
我不知道此API是否适用于最新的Android版本。
Gradle模块:compile fileTree(include: ['*.jar'], dir: 'libs')
Youtube Api的版本是1.2.2。
当应用在5.0或更高版本的Android版设备中运行时会出现此错误。
java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.youtube.api.service.START }
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.google.android.youtube.api.service.START }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:1219)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1318)
at android.app.ContextImpl.bindService(ContextImpl.java:1296)
at android.content.ContextWrapper.bindService(ContextWrapper.java:614)
at com.google.android.youtube.player.internal.r.e(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView.a(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerFragment.a(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerFragment.initialize(Unknown Source)
at breaktherules.dherediat97.musiclegends.vista.JugarConInstrumentosActivity.onCreate(JugarConInstrumentosActivity.java:94)
at android.app.Activity.performCreate(Activity.java:6303)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
breaktherules.dherediat97.musiclegends.vista.JugarConInstrumentosActivity.onCreate(JugarConInstrumentosActivity.java:94)
就是这样:
protected void onCreate(Bundle savedInstanceState) {
...
many code
...
playerFragment.initialize(Constantes.YoutubeDeveloperKey, this);
}
这门课是:
public class JugarConInstrumentosActivity extends YoutubeFailureRecovery implements YouTubePlayer.OnFullscreenListener {
答案 0 :(得分:1)
(代表OP发布)。
Android SDK版本25到19。