16

I am trying to embed a youtube video in an android app using the Youtube API. I imported the jar, added it to my build path, and added a YouTubePlayerView to my main view. In the onCreate I have the following code with my key where xxxx is :

YoutubePlayerView ytpv = (YouTubePlayerView) findViewById(R.id.youtubeplayer); ytpv.initialize("xxxx", this); 

When I run the app I get the exception :

java.lang.SecurityException: Not allowed to bind to service Intent { act=com.google.android.youtube.api.service.START } 

When I try to run the same app that comes with the api it seems to work fine. Any ideas?

3 Answers 3

30

I think you forgot to add permission:

<uses-permission android:name="android.permission.INTERNET"/> 
Sign up to request clarification or add additional context in comments.

Comments

2

It is because you didn't give internet usage permission to your Android app, because you are using YouTube player you need an internet connection.

For that you need to enter one line in your manifest.xml:

uses-permission android:name="android.permission.INTERNET" 

Don't forget to use tags before pasting it in manifest file.

Comments

0

Hi check your Android Manifest file whether you have declared Activity two times (or) check your service element and android Permissions are declared correctly . If error is not cleared post your java and Manifest file .

Check the below post for your reference

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.