Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

using youtube data in android project

My target is to use youtube instead of server, to store videos. I need youtube provide the following function 1. upload video and get his url . 2. search for video that match developer tag.

to do so, i find here those posts

Using YouTube Data Api in Android

Creating a playlist with Youtube DATA API on Android

after i read those posts i install eclipse youtube data plug in

and downloaded those file

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

as mention here https://developers.google.com/gdata/articles/eclipse?hl=iw

those zip file i add to libs folder on my android project exactly like youtube mention in the link above...

to my project i add internet permission, import packages, and add this line : YouTubeService service = new YouTubeService(clientID, developer_key);

like mention here : https://developers.google.com/youtube/2.0/developers_guide_java?hl=iw#Authentication

in this time my project look like this :

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;
    }


 }

and my project contein this jar enter image description here

at this time i test the app on my device and recieve those errors :

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

in this state i understand that, youtube data not work on android project what i need to do to order this target???

please help...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your problem is this:

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

com.google.common.collect.Maps is not found. You ether missing a library or have some problem with the manifest.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...