Issue with Android Studio Youtube imports. 'YouTubePlayerSupportFragment cannot be resolved'

∥☆過路亽.° 提交于 2019-12-01 01:37:41

Well, got it fixed, though it was due to trial and error. Basically, we had to force a gradle sync (even though the sync button in the top left did nothing, nor did rebooting).

Here are the steps I took:

First, I went into the build.gradle file (the WRONG one, the one that is for the project, not the module)

I added a compile statement there even though the comment below says not to do so, and clicked sync now.

Then, an error window popped up:

Which I did NOT click either of them. I went back into the build.gradle file:

Deleted the code I had written and then clicked try again.

After that, it magically fixed itself.

No clue why it fixed it or why it did not work in the first place, but if anyone ever comes across the same, try this and see if it helps.

-Sil

I had a similar issue. When I finally resolved it, I did NOT need anything in my build.gradle file (either one). Putting the .jar file in the libs folder was all that I need to do. Looks like you found the same result, but I wanted to list out the entire sequence of steps for clarification to anyone who reads this post.

Essentially, this is all that is required:

  1. Download the .jar file from here.
  2. Make sure that there is a folder called libs that is a sibling folder to your src folder (both should be children of the app folder.
  3. Copy that .jar file into the libs folder.
  4. Make sure that your build.gradle file (the Module: app one, not the Project: one) has this line in the dependencies section:

    compile fileTree(dir: 'libs', include: ['*.jar'])

Rebuild the project, and it should work. It did for me, at least.

Archit
compile fileTree(dir: 'libs', include: ['*.jar'])

Adding just these in Module:app just above implementation fileTree(dir: 'libs', include: ['*.jar']) solves my problem. Imports finally worked fine for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!