2

我的目标是使用 youtube 而不是服务器来存储视频。我需要 youtube 提供以下功能 1. 上传视频并获取他的网址。2. 搜索匹配开发者标签的视频。

为此,我在这里找到那些帖子

在 Android 中使用 YouTube 数据 API

在 Android 上使用 Youtube DATA API 创建播放列表

阅读这些帖子后,我安装了 eclipse youtube 数据插件

并下载了那些文件

https://code.google.com/p/gdata-java-client/downloads/detail?name=gdata-samples.java-1.47.1.zip&can=2&q=

gdata-samples.java-1.47.1
mail.jar
activation.jar
servlet-api.jar

正如这里提到的那样 https://developers.google.com/gdata/articles/eclipse?hl=iw

我添加到我的android项目的libs文件夹中的那些zip文件与上面链接中提到的youtube完全一样......

在我的项目中,我添加了互联网权限,导入包,并添加了这一行:YouTubeService service = new YouTubeService(clientID, developer_key);

喜欢这里提到: https ://developers.google.com/youtube/2.0/developers_guide_java?hl=iw#Authentication

在这个时候我的项目看起来像这样:

package com.example.youtubeuploaddata;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import com.google.gdata.client.*;
import com.google.gdata.client.youtube.*;
import com.google.gdata.data.*;
import com.google.gdata.data.geo.impl.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.media.mediarss.*;
import com.google.gdata.data.youtube.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;


public class YoutubeUploadData extends Activity {


    String clientID = "xxxxxxxxxxxxxxx";
    String developer_key = "xxxxxxxxxxxxxxxxxxxxxxx";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_youtube_upload_data);


        YouTubeService service = new YouTubeService(clientID, developer_key);


    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.youtube_upload_data, menu);
        return true;
    }


 }

我的项目包含这个罐子 在此处输入图像描述

此时我在我的设备上测试应用程序并收到这些错误:

05-01 21:10:43.993: W/dalvikvm(12171): Unable to resolve superclass of               Lcom/google/gdata/util/common/net/UriParameterMap; (26)
05-01 21:10:43.993: W/dalvikvm(12171): Link of class 'Lcom/google/gdata/util/common/net/UriParameterMap;' failed
05-01 21:10:43.993: W/dalvikvm(12171): VFY: unable to find class referenced in signature (Lcom/google/gdata/util/common/net/UriParameterMap;)
05-01 21:10:43.993: W/dalvikvm(12171): Unable to resolve superclass of Lcom/google/gdata/util/common/net/UriParameterMap; (26)
05-01 21:10:43.993: W/dalvikvm(12171): Link of class 'Lcom/google/gdata/util/common/net/UriParameterMap;' failed
05-01 21:10:43.993: W/dalvikvm(12171): VFY: unable to find class referenced in signature (Lcom/google/gdata/util/common/net/UriParameterMap;)
05-01 21:10:43.993: W/dalvikvm(12171): Unable to resolve superclass of Lcom/google/gdata/util/common/net/UriParameterMap; (26)
05-01 21:10:44.003: W/dalvikvm(12171): Link of class 'Lcom/google/gdata/util/common/net/UriParameterMap;' failed
05-01 21:10:44.003: W/dalvikvm(12171): VFY: unable to resolve static field 2621 (EMPTY_MAP) in Lcom/google/gdata/util/common/net/UriParameterMap;
05-01 21:10:44.003: W/dalvikvm(12171): Unable to resolve superclass of Lcom/google/gdata/util/common/net/UriParameterMap; (26)
05-01 21:10:44.003: W/dalvikvm(12171): Link of class 'Lcom/google/gdata/util/common/net/UriParameterMap;' failed
05-01 21:10:44.003: W/dalvikvm(12171): VFY: unable to resolve static method 8229: Lcom/google/gdata/util/common/net/UriParameterMap;.parse (Ljava/lang/String;)Lcom/google/gdata/util/common/net/UriParameterMap;
05-01 21:10:44.033: W/dalvikvm(12171): VFY: unable to resolve static method 65: Lcom/google/common/collect/Maps;.newHashMap (Ljava/util/Map;)Ljava/util/HashMap;
05-01 21:10:44.033: W/dalvikvm(12171): VFY: unable to resolve static method 64: Lcom/google/common/collect/Maps;.newHashMap ()Ljava/util/HashMap;
05-01 21:10:44.033: W/dalvikvm(12171): Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lcom/google/gdata/client/Service;
05-01 21:10:44.033: W/dalvikvm(12171): threadid=1: thread exiting with uncaught exception (group=0x40d9f1f8)
05-01 21:10:44.043: E/AndroidRuntime(12171): FATAL EXCEPTION: main
05-01 21:10:44.043: E/AndroidRuntime(12171): java.lang.ExceptionInInitializerError
05-01 21:10:44.043: E/AndroidRuntime(12171):    at com.example.youtubeuploaddata.YoutubeUploadData.onCreate(YoutubeUploadData.java:55)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.Activity.performCreate(Activity.java:4519)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.os.Looper.loop(Looper.java:137)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at android.app.ActivityThread.main(ActivityThread.java:4464)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at java.lang.reflect.Method.invokeNative(Native Method)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at java.lang.reflect.Method.invoke(Method.java:511)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:822)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at dalvik.system.NativeStart.main(Native Method)
05-01 21:10:44.043: E/AndroidRuntime(12171): Caused by: java.lang.NoClassDefFoundError: com.google.common.collect.Maps
05-01 21:10:44.043: E/AndroidRuntime(12171):    at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
05-01 21:10:44.043: E/AndroidRuntime(12171):    at com.google.gdata.client.Service.<clinit>(Service.java:555)
05-01 21:10:44.043: E/AndroidRuntime(12171):    ... 15 more

在这种状态下,我明白,youtube 数据不适用于 android 项目我需要做什么才能订购这个目标???

请帮忙...

4

2 回答 2

2

你的问题是这样的:

Caused by: java.lang.NoClassDefFoundError: com.google.common.collect.Maps

com.google.common.collect.Maps没有找到。您缺少库或清单有问题。

于 2013-05-03T15:25:37.347 回答
1

随意浏览我的示例开源项目,它为此使用了 Data API v3.. https://code.google.com/p/ytd-android/

于 2013-05-03T14:44:08.993 回答