akoscz / YouTubePlaylist

A sample Android application which demonstrates the use of the YouTube Data v3 API.
Apache License 2.0
153 stars 84 forks source link

java.lang.NullPointerException #12

Closed Superhuman07 closed 7 years ago

Superhuman07 commented 8 years ago

Hi i am running your app on my device and using my api key it force closes and has this error in the lines:- FATAL EXCEPTION: main Process: com.akoscz.youtube, PID: 27594 Theme: themes:{} java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.google.api.services.youtube.model.PlaylistListResponse.getItems()' on a null object reference at com.akoscz.youtube.YouTubeRecyclerViewFragment$1.onPostExecute(YouTubeRecyclerViewFragment.java:98) at com.akoscz.youtube.YouTubeRecyclerViewFragment$1.onPostExecute(YouTubeRecyclerViewFragment.java:93) at android.os.AsyncTask.finish(AsyncTask.java:651) at android.os.AsyncTask.-wrap1(AsyncTask.java) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5461) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

Can you provide solution to this error?

Update :- I learned from one of the issues from your profile that the app needs browser key please update your readme.

akoscz commented 8 years ago

Hi @Superhuman07. Using a Browser key is good for development as a quick solution. But ultimately if you're going to deploy your app to the Google Play Store you should use an Android key built with the SHA1 of your release certificate. See https://developers.google.com/youtube/registering_an_application#android-installed-application-credentials

If you do not publish your app to the Google Play Store, then you should just use a Browser key.

As for the NPE, that's a bug. It should not crash. I will get that fixed in a couple of days when I have some time. Thanks for the report.

Superhuman07 commented 8 years ago

Ok cool! Thanks for the reply.

akoscz commented 8 years ago

Re-opening issue so that I don't forget to fix the NPE :)

goodlifechris commented 8 years ago

Its nort really working the nullpointer error exists any help

thoinv commented 7 years ago

You must use "Browser API key" (Server key) because execute() method is part of java client api and not Android Client API