android项目youtube客户端中,我采用google提供的第三方jar包,在java工程里运行一点问题都没有,为何在android模拟器中跑起来抛出错误 Could not find class 'com.google.gdata.client.youtube.YouTubeService', referenced from  method com.hisoft.MainActivity$1.onClick
  java.lang.NoClassDefFoundError: com.google.gdata.client.youtube.YouTubeService
YouTubeService类为何找不到呢?请高手指点
具体代码如下:package com.niit;import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import com.google.gdata.client.youtube.YouTubeService;
import com.google.gdata.data.youtube.VideoFeed;
import com.google.gdata.util.ServiceException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class MainActivity extends Activity {
private Button bt; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bt = (Button) findViewById(R.id.button01);
bt.setOnClickListener(new OnClickListener() { @Override
public void onClick(View v) {
Log.i("title", "hello");
YouTubeService myService = new YouTubeService(
"gdataSample-YouTube-1");
Log.i("title", "hello2");
String url = "https://gdata.youtube.com/feeds/api/videos?start-       index=1&max-results=5&prettyprint=true&q=football";
try {
Log.i("title", "abcc");
VideoFeed videoFeed = myService.getFeed(new URL(url),
VideoFeed.class);
String title = videoFeed.getTitle().getPlainText(); Log.i("title", title);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
} }
});
}
}

解决方案 »

  1.   

    build path里设置添加google api对应的jar文件
      

  2.   

      jar包我都添加了,可一直都抛错呢!
      

  3.   

    在主activity里面oncreate应该加这句吧:
    Intent Intentser = new Intent(this, YouTubeService.class);
    this.startService(Intentser);
      

  4.   

      
                谢谢,加这句不行吧?。我不需要启动服务,YuTubeService是google第三方jar包里 给我们封装好的类有没有高手啊???赐教!!!
      

  5.   

    能导入说明你的jar包里面有这类。
    楼主的第三方jar包不会叫android.jar吧
      

  6.   

                  google提供的哇!有将近10个包
    gdata-2.2.1-alpha.jar        gdata-core-1.0.jargdata-core-1.0.jar   gdata-youtube-meta-2.0.jar等
      

  7.   

    天哪,这位兄弟跟我遇到的问题是惊人的相似啊,而且都是做YouTube客户端!汗,我就搞不懂我们公司为啥要自己弄个YouTube客户端,人家官方都已经有一个android的客户端了
      

  8.   

    还要activation.jar google-collect-1.0-rc1.jar jsr305.jar mail.jar