3

I have placed api jar file in libs folder.When I run this program,I'm getting Unfortunately,youtube player has stopped working.

Can anyone help me?

one more thing I want to know: I have used this below statement in java file. it is showing redmark at DEVELOPER_KEY(actually this is a variable storing api key), youTubeView.initialize(Config.DEVELOPER_KEY, this); That is why i have used below statement: youTubeView.initialize(DEVELOPER_KEY,this);

Is there any problem because of this

This is my activity.java

    package com.example.XXX.XXX;

    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.os.Bundle;
    import android.view.Window;
    import android.view.WindowManager;
    import android.widget.Toast;

    import com.google.android.youtube.player.YouTubeBaseActivity;
    import com.google.android.youtube.player.YouTubeInitializationResult;
    import com.google.android.youtube.player.YouTubePlayer;
    import com.google.android.youtube.player.YouTubePlayer.PlayerStyle;
    import com.google.android.youtube.player.YouTubePlayerView;

    public class YoutubeActivity extends YouTubeBaseActivity implements
            YouTubePlayer.OnInitializedListener {
        public static final String DEVELOPER_KEY = "<Censored>";
        public static final String YOUTUBE_VIDEO_CODE = "uOpVvokKnu0";

        private static final int RECOVERY_DIALOG_REQUEST = 1;

        // YouTube player view
        private YouTubePlayerView youTubeView;

        @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.activity_main);

            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(YOUTUBE_VIDEO_CODE);

                // 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(DEVELOPER_KEY,this);
            }
        }

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

    }

`

This is my XML code

`

        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_centerInParent="true"
            android:scaleType="centerCrop"
            android:src="@drawable/snake_bg" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_marginLeft="30dp"
            android:layout_marginRight="30dp"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/rouned_corner_shadow"
                android:gravity="center_horizontal"
                android:orientation="vertical" >

                <com.google.android.youtube.player.YouTubePlayerView
                    android:id="@+id/youtube_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="30dp" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="70dp"
                    android:layout_marginBottom="20dp"
                    android:scaleType="fitCenter"
                    android:src="@drawable/nat_geo_logo" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="10dp"
                    android:text="@string/title_logo"
                    android:textColor="@color/title"
                    android:textSize="20dp"
                    android:textStyle="bold" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="40dp"
                    android:layout_marginBottom="30dp"
                    android:scaleType="fitCenter"
                    android:src="@drawable/wild" />
            </LinearLayout>

            <Button
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="40dp"
                android:background="@drawable/rouned_corner_shadow"
                android:text="@string/btn_skip_intro" />
        </LinearLayout>

    </RelativeLayout>

`

Log cat output:

at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                at android.os.Looper.loop(Looper.java:136)
                                at android.app.ActivityThread.main(ActivityThread.java:5017)
                                at java.lang.reflect.Method.invokeNative(Native Method)
                                at java.lang.reflect.Method.invoke(Method.java:515)
                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                at dalvik.system.NativeStart.main(Native Method)
                         Caused by: java.lang.NullPointerException
                                at com.example.health.weshallovercome.YoutubeActivity.onCreate(YoutubeActivity.java:38)
                                at android.app.Activity.performCreate(Activity.java:5231)
                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                at android.os.Looper.loop(Looper.java:136)
                                at android.app.ActivityThread.main(ActivityThread.java:5017)
                                at java.lang.reflect.Method.invokeNative(Native Method)
                                at java.lang.reflect.Method.invoke(Method.java:515)
                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                at dalvik.system.NativeStart.main(Native Method)

Because of this below code I'm getting some errors on design view. I'll attach that.

<com.google.android.youtube.player.YouTubePlayerView android:id="@+id/youtube_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="30dp" />

That is error I'm getting on XML file

this is the continuation for this error

Please find the logcat:

05-04 06:24:29.670      935-935/XXX D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
                    05-04 06:24:31.580      935-935/XXX D/dalvikvm﹕ GC_FOR_ALLOC freed 48K, 5% free 2808K/2940K, paused 248ms, total 333ms
                    05-04 06:24:31.580      935-935/XXX I/dalvikvm-heap﹕ Grow heap (frag case) to 9.002MB for 6480016-byte allocation
                    05-04 06:24:32.030      935-944/XXX D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 2% free 9136K/9272K, paused 453ms, total 453ms
                    05-04 06:24:33.410      935-935/XXX D/﹕ HostConnection::get() New Host Connection established 0xb7550c78, tid 935
                    05-04 06:24:33.550      935-935/XXX W/EGL_emulation﹕ eglSurfaceAttrib not implemented
                    05-04 06:24:33.570      935-935/XXX D/OpenGLRenderer﹕ Enabling debug mode 0
                    05-04 06:28:24.979      935-935/XXX W/EGL_emulation﹕ eglSurfaceAttrib not implemented
                    05-04 06:28:27.559      935-935/XXX D/dalvikvm﹕ GC_FOR_ALLOC freed 29K, 2% free 11093K/11216K, paused 41ms, total 42ms
                    05-04 06:28:27.769      935-935/XXX W/EGL_emulation﹕ eglSurfaceAttrib not implemented
                    05-04 06:28:30.839      935-935/XXX D/AndroidRuntime﹕ Shutting down VM
                    05-04 06:28:30.839      935-935/XXX W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb3ab8ba8)
                    05-04 06:28:30.869      935-935/XXX E/AndroidRuntime﹕ FATAL EXCEPTION: main
                        Process: XXX, PID: 935
                        java.lang.RuntimeException: Unable to start activity ComponentInfo{XXX/XXX.YoutubeActivity}: java.lang.NullPointerException
                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                at android.os.Looper.loop(Looper.java:136)
                                at android.app.ActivityThread.main(ActivityThread.java:5017)
                                at java.lang.reflect.Method.invokeNative(Native Method)
                                at java.lang.reflect.Method.invoke(Method.java:515)
                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                at dalvik.system.NativeStart.main(Native Method)
                         Caused by: java.lang.NullPointerException
                                at XXX.YoutubeActivity.onCreate(YoutubeActivity.java:38)
                                at android.app.Activity.performCreate(Activity.java:5231)
                                at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                                at android.app.ActivityThread.access$800(ActivityThread.java:135)
                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                at android.os.Looper.loop(Looper.java:136)
                                at android.app.ActivityThread.main(ActivityThread.java:5017)
                                at java.lang.reflect.Method.invokeNative(Native Method)
                                at java.lang.reflect.Method.invoke(Method.java:515)
                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                                at dalvik.system.NativeStart.main(Native Method)
                    05-04 06:28:35.489      935-935/XXX I/Process﹕ Sending signal. PID: 935 SIG: 9
                    05-04 06:28:36.699    1148-1148/XXX  D/dalvikvm﹕ GC_FOR_ALLOC freed 40K, 5% free 2809K/2936K, paused 39ms, total 40ms
                    05-04 06:28:36.939    1148-1161/XXX D/dalvikvm﹕ GC_FOR_ALLOC freed 16K, 3% free 3308K/3408K, paused 24ms, total 24ms
                    05-04 06:28:37.219    1148-1148/XXX D/﹕ HostConnection::get() New Host Connection established 0xb769ae50, tid 1148
                    05-04 06:28:37.289    1148-1148/XXX W/EGL_emulation﹕ eglSurfaceAttrib not implemented
                    05-04 06:28:37.309    1148-1148/XXX D/OpenGLRenderer﹕ Enabling debug mode 0

I have followed this below link for playing youtube in android app. http://www.androidhive.info/2014/12/how-to-play-youtube-video-in-android-app/ Changes I have made in my app are: I added this below line Androidmanifest.xml as said earlier: I have added below line in build.gradle: compile files('libs/YouTubeAndroidPlayerApi.jar')

I have added this jar in libs folder. I have already keep the code of code my xml and java file in this question. I have followed that tutorial completely.

Are you not getting any problems because of below code in xml:

<com.google.android.youtube.player.YouTubePlayerView
                android:id="@+id/youtube_view"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="30dp" />

And I have created config.java in java folder:

code of config.java as:

public class config {
                // Google Console APIs developer key
                // Replace this key with your's
                public static final String DEVELOPER_KEY = "";

                // YouTube video id
                public static final String YOUTUBE_VIDEO_CODE = "uOpVvokKnu0";  }

Screenshot of where I have added jar file

As I don't have 20 reputations,I can't chat. I have one more account,it has more than 20 reputations.But i'm unable to find you there.

We are almost reached,Please help me.

Can you please enable the chat now? I have more than 20 reputations. I can chat.

And also please find the present logcat:

05-06 02:27:38.110 991-991/com.example.health.weshallovercome D/AndroidRuntime﹕ Shutting down VM 05-06 02:27:38.110 991-991/com.example.health.weshallovercome W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb3a3fba8) 05-06 02:27:38.140 991-991/com.example.health.weshallovercome E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.health.weshallovercome, PID: 991 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.health.weshallovercome/com.example.health.weshallovercome.YoutubeActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.example.health.weshallovercome.YoutubeActivity.onCreate(YoutubeActivity.java:19) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)             at android.app.ActivityThread.access$800(ActivityThread.java:135)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)             at android.os.Handler.dispatchMessage(Handler.java:102)             at android.os.Looper.loop(Looper.java:136)             at android.app.ActivityThread.main(ActivityThread.java:5017)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)             at dalvik.system.NativeStart.main(Native Method) 05-06 02:27:46.480 991-991/com.example.health.weshallovercome I/Process﹕ Sending signal. PID: 991 SIG: 9 05-06 02:27:47.510 1010-1010/com.example.health.weshallovercome D/dalvikvm﹕ GC_FOR_ALLOC freed 59K, 5% free 2809K/2940K, paused 52ms, total 53ms 05-06 02:27:47.510 1010-1010/com.example.health.weshallovercome I/dalvikvm-heap﹕ Grow heap (frag case) to 3.258MB for 472516-byte allocation 05-06 02:27:47.560 1010-1019/com.example.health.weshallovercome D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 4% free 3271K/3404K, paused 39ms, total 39ms 05-06 02:27:47.960 1010-1010/com.example.health.weshallovercome D/﹕ HostConnection::get() New Host Connection established 0xb7c64710, tid 1010 05-06 02:27:48.050 1010-1010/com.example.health.weshallovercome W/EGL_emulation﹕ eglSurfaceAttrib not implemented 05-06 02:27:48.070 1010-1010/com.example.health.weshallovercome D/OpenGLRenderer﹕ Enabling debug mode 0 05-06 02:27:50.180 1010-1010/com.example.health.weshallovercome D/dalvikvm﹕ GC_FOR_ALLOC freed 24K, 3% free 3597K/3692K, paused 30ms, total 31ms 05-06 02:27:50.280 1010-1010/com.example.health.weshallovercome D/dalvikvm﹕ GC_FOR_ALLOC freed 3K, 3% free 3966K/4068K, paused 30ms, total 31ms 05-06 02:27:50.380 1010-1010/com.example.health.weshallovercome D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 3% free 4338K/4444K, paused 31ms, total 31ms 05-06 02:27:50.760 1010-1010/com.example.health.weshallovercome W/EGL_emulation﹕ eglSurfaceAttrib not implemented 05-06 02:27:54.760 1010-1010/com.example.health.weshallovercome D/dalvikvm﹕ GC_FOR_ALLOC freed 22K, 2% free 4837K/4928K, paused 34ms, total 34ms 05-06 02:27:54.970 1010-1010/com.example.health.weshallovercome I/dalvikvm﹕ Could not find method android.view.ViewGroup.onNestedScrollAccepted, referenced from method android.support.v7.internal.widget.ActionBarOverlayLayout.onNestedScrollAccepted 05-06 02:27:54.970 1010-1010/com.example.health.weshallovercome W/dalvikvm﹕ VFY: unable to resolve virtual method 12609: Landroid/view/ViewGroup;.onNestedScrollAccepted (Landroid/view/View;Landroid/view/View;I)V

And as you told I didn't find add as library option in right click menu. And also I added the jar file not through studio. I have opened Androidstudioprojects(which is present in C) and I have choosen my project,in that I opened libs and copied jar file. It is showing that jar file under libs in my project.I dont think that is the wrong way of adding jar,is it? right click menu

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
  • Post you logcat output. – Vigneshwaran Murugesan May 02 '15 at 10:53
  • 05-04 02:45:30.116 915-915/com.example.health.weshallovercome E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.health.weshallovercome, PID: 915 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.health.weshallovercome/com.example.health.weshallovercome.YoutubeActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) – stackforme stack May 04 '15 at 06:59
  • Continuation: at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) – stackforme stack May 04 '15 at 06:59
  • at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.example.health.weshallovercome.YoutubeActivity.onCreate(YoutubeActivity.java:38) – stackforme stack May 04 '15 at 07:00
  • at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)             at android.app.ActivityThread.access$800(ActivityThread.java:135)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)             at android.os.Handler.dispatchMessage(Handler.java:102) – stackforme stack May 04 '15 at 07:00
  • at android.os.Looper.loop(Looper.java:136)             at android.app.ActivityThread.main(ActivityThread.java:5017)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:515)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)             at dalvik.system.NativeStart.main(Native Method) – stackforme stack May 04 '15 at 07:00
  • If you need any thing more,please inform me... – stackforme stack May 04 '15 at 07:01
  • could you please post the logs on your OP(question) instead of commenting here. – Vigneshwaran Murugesan May 04 '15 at 07:01
  • i have pasted it below the question...please find..And thanks for reply. – stackforme stack May 04 '15 at 07:41
  • in which device you have tested this code? – Vigneshwaran Murugesan May 04 '15 at 08:14
  • I have tested in Android studio and moto g2. Please find the question block once.. I have added error which is coming at activity.xml file. If you need any more info,please inform me. – stackforme stack May 04 '15 at 10:45
  • I have tested your code and it is working properly without of any crashes could you please post the latest logcat trace. – Vigneshwaran Murugesan May 04 '15 at 12:00
  • 1
    For the sake of sanity on Stackoverflow and leaking your information, I have taken the liberty of censoring your Dev Key. DO NOT post this information on stackoverflow. – JoxTraex May 05 '15 at 06:03

1 Answers1

0

I have tested your code and i felt like fool when the issue is internet permission. Add this to your AndroidManifest.xml:

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

Make sure you have a valid API key since the YoutubePlayer API doc says.

If you do not set the developer key, the samples will throw a java.lang.NullPointerException and close when you attempt to run them.

EDIT:

For fixing the layout rendering issues use tools:context as

<AnyRootLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".YouTubeActivit" <!-- Your activity name here -->
    >
<!-- Your child elements here -->
</AnyRootElement>

Add the jar file into the libs folder and right click on that jar file and click on "Add as library" more info on adding a jar file in android studio here

My Build.gradle (for app module):

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.mypackage.youtubedemo"
    minSdkVersion 9
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

    dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
Community
  • 1
  • 1
  • This statement is already there in my AndroidManifest.xml. I have added it for internet permission as I read in some blog. – stackforme stack May 04 '15 at 10:34
  • I have tested your code and it is working properly did you installed could you provide the full logcat trace so that i can check. – Vigneshwaran Murugesan May 04 '15 at 11:28
  • I have added logcat and changes what i made in my files. When I'm running this code,I'm getting error: "Unfortunately,Youtube Player has stopped." – stackforme stack May 04 '15 at 12:22
  • I have checked the code in Android studio too and its working fine did you added the jar file right click on the jar file under libs folder and click Add as library or see here for more details(https://developer.android.com/sdk/installing/create-project.html#ReferencingLibraryModule) – Vigneshwaran Murugesan May 04 '15 at 12:54
  • Is it playing the video in your emulator? And just we need to place the jar file under libs folder and we need to update that in build.gradle file,is that correct? I have added the screenshot of libs folder. please find it. Many thanks for your help. – stackforme stack May 04 '15 at 13:23
  • Place he jar file under libs folder and right click on that jar file and click on it will update the gradle script by itself you dont have to do anything manually in the gradle script. I have also posted my gradle script here – Vigneshwaran Murugesan May 06 '15 at 03:57