有人可以让我知道 YouTube API 获取观看次数所需的 jar 文件和导入库是什么吗

Can someone please let me know what are the jar files and import libraries needed for YouTube APIs to get view count

我正在尝试从 YouTube API 中找出 YouTube 视频的观看次数,并找到了一些代码来执行此操作。但是我无法编译代码,因为它需要 jar 文件和导入库。请帮忙

YouTube youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer());

YouTube.Videos.List videoRequest = youtube.videos().list("contentDetails");
videoRequest.setId("SOME-VIDEO-ID");
videoRequest.setFields("items/contentDetails");
videoRequest.setKey("YOUR-API-KEY");
VideoListResponse response = videoRequest.execute(); //blocking call, ensure to perform off ui thread via AsyncTask 
List<Video> videosList = response.getItems(); 

if(videosList != null && videosList.size() > 0){
 Video video = videosList.get(0);
 VideoStatistics statistics = video.getStatistics();
 BigInteger viewCount = statistics.getViewCount();
}

错误如下: 执行任务:[:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]

按需配置是一项孵化功能。 警告:调试时忽略依赖项 org.apache.httpcomponents:httpclient:4.0.1,因为它可能与 Android 提供的内部版本冲突。 如有问题,请用jarjar重新打包,更改class包 警告:依赖项 org.apache.httpcomponents:httpclient:4.0.1 在发布时被忽略,因为它可能与 Android 提供的内部版本冲突。 如有问题,请用jarjar重新打包,更改class包 :app:preBuild 最新 :app:preDebugBuild 最新版本 :应用程序:检查调试清单 :app:preReleaseBuild 最新版本 :app:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE :app:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42310Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl 最新 :app:compileDebugRenderscript 最新 :app:generateDebugBuildConfig 最新 :app:generateDebugAssets 最新 :app:mergeDebugAssets 最新 :app:generateDebugResValues 最新 :app:generateDebugResources 最新 :app:mergeDebugResources 最新 :app:processDebugManifest 最新 :app:processDebugResources 最新 :app:generateDebugSources 最新 :app:preDebugAndroidTestBuild 最新 :app:prepareDebugAndroidTestDependencies :app:compileDebugAndroidTestAidl 最新 :app:processDebugAndroidTestManifest UP-TO-DATE :app:compileDebugAndroidTestRenderscript 最新 :app:generateDebugAndroidTestBuildConfig 最新 :app:generateDebugAndroidTestAssets 最新 :app:mergeDebugAndroidTestAssets 最新 :app:generateDebugAndroidTestResValues 最新 :app:generateDebugAndroidTestResources UP-TO-DATE :app:mergeDebugAndroidTestResources UP-TO-DATE :app:processDebugAndroidTestResources UP-TO-DATE :app:generateDebugAndroidTestSources UP-TO-DATE :app:processDebugJavaRes 最新 :app:compileDebugJavaWithJavac 最新 :app:compileDebugNdk 最新 :app:compileDebugSources 最新 :应用程序:preDexDebug AGPBI: {"kind":"simple","text":"trouble processing \"javax/transaction/HeuristicCommitException.class\":","sources":[{ }]} AGPBI:{"kind":"simple","text":"Ill-advised or mistaken usage of a core class (java.* or javax.*)","sources":[{}]} AGPBI:{"kind":"simple","text":"when not building a core library.","sources":[{}]} AGPBI:{"kind":"simple","text":"This is often due to inadvertently including a core library file","sources":[{}]} AGPBI:{"kind":"simple","text":"in your application\u0027s project, when using an IDE (such as","sources":[{}]} AGPBI:{"kind":"simple","text":"Eclipse). If you are sure you\u0027re not intentionally defining a","sources":[{}]} AGPBI:{"kind":"simple","text":"core class, then this is the most likely explanation of what\u0027s","sources":[{}]} AGPBI:{"kind":"simple","text":"going on.","sources":[{}]} AGPBI:{"kind":"simple","text":"However, you might actually be trying to define a class in a core","sources":[{}]} AGPBI:{"kind":"simple","text":"namespace, the source of which you may have taken, for example,","sources":[{}]} AGPBI:{"kind":"simple","text":"from a non-Android virtual machine project. This will most","sources":[{}]} AGPBI:{"kind":"simple","text":"assuredly not work. At a minimum, it jeopardizes the","sources":[{}]} AGPBI:{"kind":"simple","text":"compatibility of your app with future versions of the platform.","sources":[{}]} AGPBI:{"kind":"simple","text":"It is also often of questionable legality.","sources":[{}]} AGPBI:{"kind":"simple","text":"If you really intend to build a core library -- which is only","sources":[{}]} AGPBI:{"kind":"simple","text":"appropriate as part of creating a full virtual machine","sources":[{}]} AGPBI:{"kind":"simple","text":"distribution, as opposed to compiling an application -- then use","sources":[{}]} AGPBI: {"kind":"simple","text":"the \"--core-library\" 抑制此错误消息的选项。","sources":[{ }]} AGPBI: {"kind":"simple","text":"If you go ahead and use \"--core-library\" 但实际上是","sources":[{}]} AGPBI:{"kind":"simple","text":"building an application, then be forewarned that your application","sources":[{}]} AGPBI:{"kind":"simple","text":"will still fail to build or run, at some point. Please be","sources":[{}]} AGPBI:{"kind":"simple","text":"prepared for angry customers who find, for example, that your","sources":[{}]} AGPBI:{"kind":"simple","text":"application ceases to function once they upgrade their operating","sources":[{}]} AGPBI:{"kind":"simple","text":"system. You will be to blame for this problem.","sources":[{}]} AGPBI:{"kind":"simple","text":"If you are legitimately using some code that happens to be in a","sources":[{}]} AGPBI:{"kind":"simple","text":"core package, then the easiest safe alternative you have is to","sources":[{}]} AGPBI:{"kind":"simple","text":"repackage that code. That is, move the classes in question into","sources":[{}]} AGPBI:{"kind":"simple","text":"your own package namespace. This means that they will never be in","sources":[{}]} AGPBI:{"kind":"simple","text":"conflict with core system classes. JarJar is a tool that may help","sources":[{}]} AGPBI:{"kind":"simple","text":"you in this endeavor. If you find that you cannot do this, then","sources":[{}]} AGPBI:{"kind":"simple","text":"that is an indication that the path you are on will ultimately","sources":[{}]} AGPBI:{"kind":"simple","text":"lead to pain, suffering, grief, and lamentation.","sources":[{}]} AGPBI:{"kind":"simple","text":"1 个错误;中止","sources":[{}]}

失败

失败:构建失败,出现异常。

构建失败

我想你想要的库是这些:

https://developers.google.com/api-client-library/java/apis/youtube/v3

可能还需要阅读此内容以涵盖 android 设置

https://developers.google.com/api-client-library/java/google-api-java-client/android

这是我目前使用的(在 gradle 版本上)

    compile('com.google.apis:google-api-services-youtube:v3-rev144-1.20.0') {
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }

只需将该行粘贴到 build.gradle 文件中。

我可以通过仅添加所需的 jar 文件来解决错误: 1) YouTubeAndroidPlayerApi.jar 2) google-api-services-youtube-v3-rev152-1.21.0.jar 3) google-http-client-android-1.20.0.jar 4) google-api-客户端-android-1.20.0.jar

构建Gradle文件

    compile 'com.google.apis:google-api-services-youtube:v3-rev152-1.21.0'