添加YouTube数据API到Android工作室 [英] Add youtube data api to android studio

查看:322
本文介绍了添加YouTube数据API到Android工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我目前瞎搞了Android程序在我的空闲时间,而我使用的Andr​​oid工作室作为我的首选IDE。目前我正在试图让使用YouTube API一个非常简单的应用程序。我的问题是,我无法弄清楚如何真正得到的API到我的应用程序。我已经使用的文件>项目结构的东西添加到我的应用程序,但本身不工作。它停止叫喊我关于语法错误,但是当它编译它的错误。

So, I am currently messing around with android programming in my free time, and I am using android studio as my ide of choice. I am currently trying to make a very simple app using the youtube api. My issue is that I cant figure out how to actually get the api into my application. I have used file>project structure to add the stuff to my application, but that doesnt work by itself. It stops yelling at me about syntax errors but when it compiles it errors.

我这个研究了一下,发现我需要添加的东西build.gradle或settings.gradle(或两者),但我还没有发现到底该怎么做一个明确的答案。一切我都试过迄今处理不当的工作。因此,如果有人既可以向我解释什么,我要做的,或链接我在那里解释了这样做将是巨大的地方

I researched this a bit and have found that I need to add stuff to build.gradle or settings.gradle(or both) but i havent found a definitive answer on exactly what to do. Everything I have tried thus far hasnt worked. SO if someone could either explain to me what i have to do, or link me to a place where it explains what to do that would be great

- 编辑 -

我sooooooooo困惑现在。我开始一个新项目。我加了库,它依然能编译。然后我说了进口,并投掷了它的错误。然后我说这些的build.gradle,它是能够完美编译

I am sooooooooo confused right now. I started a new project. I added the libs and it was still able to compile. I then added the imports and it threw errors about it. I then added these to the build.gradle and it was able to compile perfectly

compile fileTree(dir: 'libs/youtube', include: '*.jar')
compile fileTree(dir: 'libs/youtube/libs', include: '*.jar')

但是,当我说这code,需要的库

But when i added this code that requires the library

/** Global instance of the HTTP transport. */
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

/** Global instance of the JSON factory. */
private static final JsonFactory JSON_FACTORY = new JacksonFactory();

/** Global instance of Youtube object to make all API requests. */
private static YouTube youtube;

语法很不错,但它在编译抛出错误它

the syntax was fine but it threw an error upon compiling it

 Gradle: Execution failed for task ':Apitest:dexDebug'.
> Failed to run command:

和随后是约100行的文件位置的

and that was followed by about 100 lines of of file locations

任何想法,我做错了什么?

Any ideas as to what i am doing wrong?

推荐答案

只需添加这种依赖于摇篮文件:

Just add this dependency in gradle file:

compile 'com.google.apis:google-api-services-youtube:v3-rev120-1.19.0'

和使用YouTube的对象。

and use YouTube object.

这篇关于添加YouTube数据API到Android工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆