Android 在尝试从 YouTube 获取数据时崩溃?

发布于 2024-11-28 06:16:35 字数 3805 浏览 2 评论 0原文

我得到了这个片段,它应该是从 YouTube 上吐出某些视频的标题。

 public static void getVids() {
        try {
            YouTubeService myService = new YouTubeService("mycompany-myapp-1");
            String myFeed = "http://gdata.youtube.com/feeds/videos?start-index=1&max-results=25&vq=lizards&oi=spell";
            printVideoFeed(myService, myFeed);
        } catch (IOException ex) {
            Toast toast = Toast.makeText(null, "Error "+ex.toString(), 5000);
            toast.show();
        } catch (ServiceException ex) {
            Toast toast = Toast.makeText(null, "Error "+ex.toString(), 5000);
            toast.show();
        }
    }

    private static void printVideoFeed(YouTubeService service, String feedUrl) throws IOException, ServiceException {
        VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class);
        List<VideoEntry> allVideos = videoFeed.getEntries();
        Iterator<VideoEntry> itAllVideos = allVideos.iterator();
        String Titles = "";
        while (itAllVideos.hasNext()){
            VideoEntry oneVideo  = itAllVideos.next();
            TextConstruct oneVideoTitle = oneVideo.getTitle();
            Titles = Titles + " | " + oneVideoTitle.toString();
        }

        Toast toast = Toast.makeText(null, "Working! " + Titles , 5000);
        toast.show();

    }

但是当我执行它时它崩溃了。 logcat 的内容如下:

08-05 17:33:30.203: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/MediaSource; interface 1435 'Ljavax/activation/DataSource;'
08-05 17:33:30.207: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaSource;' failed
08-05 17:33:30.207: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/BaseMediaSource; interface 452 'Lcom/google/gdata/data/media/MediaSource;'
08-05 17:33:30.207: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/BaseMediaSource;' failed
08-05 17:33:30.207: WARN/dalvikvm(13832): Unable to resolve superclass of Lcom/google/gdata/data/media/MediaStreamSource; (435)
08-05 17:33:30.207: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaStreamSource;' failed
08-05 17:33:30.207: ERROR/dalvikvm(13832): Could not find class 'com.google.gdata.data.media.MediaStreamSource', referenced from method com.google.gdata.client.media.MediaService.getMediaResource
08-05 17:33:30.207: WARN/dalvikvm(13832): VFY: unable to resolve new-instance 453 (Lcom/google/gdata/data/media/MediaStreamSource;) in Lcom/google/gdata/client/media/MediaService;
08-05 17:33:30.207: DEBUG/dalvikvm(13832): VFY: replacing opcode 0x22 at 0x0013
08-05 17:33:30.207: DEBUG/dalvikvm(13832): VFY: dead code 0x0015-0039 in Lcom/google/gdata/client/media/MediaService;.getMediaResource (Ljava/net/URL;Lcom/google/gdata/util/ContentType;Lcom/google/gdata/data/DateTime;)Lcom/google/gdata/data/media/MediaSource;
08-05 17:33:30.210: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/MediaSource; interface 1435 'Ljavax/activation/DataSource;'
08-05 17:33:30.210: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaSource;' failed
08-05 17:33:30.210: WARN/dalvikvm(13832): VFY: unable to find class referenced in signature (Lcom/google/gdata/data/media/MediaSource;)
08-05 17:33:30.210: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/MediaSource; interface 1435 'Ljavax/activation/DataSource;'
08-05 17:33:30.210: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaSource;' failed
08-05 17:33:30.210: INFO/dalvikvm(13832): Could not find method com.google.gdata.data.media.MediaSource.getName, referenced from method com.google.gdata.client.media.MediaService.initMediaRequest

...

您认为问题可能是什么?

谢谢!

I got this snippet, which was supposed to toast out titles of certain videos from youtube.

 public static void getVids() {
        try {
            YouTubeService myService = new YouTubeService("mycompany-myapp-1");
            String myFeed = "http://gdata.youtube.com/feeds/videos?start-index=1&max-results=25&vq=lizards&oi=spell";
            printVideoFeed(myService, myFeed);
        } catch (IOException ex) {
            Toast toast = Toast.makeText(null, "Error "+ex.toString(), 5000);
            toast.show();
        } catch (ServiceException ex) {
            Toast toast = Toast.makeText(null, "Error "+ex.toString(), 5000);
            toast.show();
        }
    }

    private static void printVideoFeed(YouTubeService service, String feedUrl) throws IOException, ServiceException {
        VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class);
        List<VideoEntry> allVideos = videoFeed.getEntries();
        Iterator<VideoEntry> itAllVideos = allVideos.iterator();
        String Titles = "";
        while (itAllVideos.hasNext()){
            VideoEntry oneVideo  = itAllVideos.next();
            TextConstruct oneVideoTitle = oneVideo.getTitle();
            Titles = Titles + " | " + oneVideoTitle.toString();
        }

        Toast toast = Toast.makeText(null, "Working! " + Titles , 5000);
        toast.show();

    }

But it crashes when I execute it. Here's what logcat says:

08-05 17:33:30.203: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/MediaSource; interface 1435 'Ljavax/activation/DataSource;'
08-05 17:33:30.207: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaSource;' failed
08-05 17:33:30.207: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/BaseMediaSource; interface 452 'Lcom/google/gdata/data/media/MediaSource;'
08-05 17:33:30.207: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/BaseMediaSource;' failed
08-05 17:33:30.207: WARN/dalvikvm(13832): Unable to resolve superclass of Lcom/google/gdata/data/media/MediaStreamSource; (435)
08-05 17:33:30.207: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaStreamSource;' failed
08-05 17:33:30.207: ERROR/dalvikvm(13832): Could not find class 'com.google.gdata.data.media.MediaStreamSource', referenced from method com.google.gdata.client.media.MediaService.getMediaResource
08-05 17:33:30.207: WARN/dalvikvm(13832): VFY: unable to resolve new-instance 453 (Lcom/google/gdata/data/media/MediaStreamSource;) in Lcom/google/gdata/client/media/MediaService;
08-05 17:33:30.207: DEBUG/dalvikvm(13832): VFY: replacing opcode 0x22 at 0x0013
08-05 17:33:30.207: DEBUG/dalvikvm(13832): VFY: dead code 0x0015-0039 in Lcom/google/gdata/client/media/MediaService;.getMediaResource (Ljava/net/URL;Lcom/google/gdata/util/ContentType;Lcom/google/gdata/data/DateTime;)Lcom/google/gdata/data/media/MediaSource;
08-05 17:33:30.210: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/MediaSource; interface 1435 'Ljavax/activation/DataSource;'
08-05 17:33:30.210: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaSource;' failed
08-05 17:33:30.210: WARN/dalvikvm(13832): VFY: unable to find class referenced in signature (Lcom/google/gdata/data/media/MediaSource;)
08-05 17:33:30.210: INFO/dalvikvm(13832): Failed resolving Lcom/google/gdata/data/media/MediaSource; interface 1435 'Ljavax/activation/DataSource;'
08-05 17:33:30.210: WARN/dalvikvm(13832): Link of class 'Lcom/google/gdata/data/media/MediaSource;' failed
08-05 17:33:30.210: INFO/dalvikvm(13832): Could not find method com.google.gdata.data.media.MediaSource.getName, referenced from method com.google.gdata.client.media.MediaService.initMediaRequest

...

What do you think might be the problem?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

很糊涂小朋友 2024-12-05 06:16:36

YouTube API 团队直接表示:“我的理解是 Java Google 数据客户端库目前与 Android 运行时环境不兼容。”

此链接是我找到该答案的地方您看到的错误消息。

Straight from the YouTube API team: "My understanding is that the Java Google Data client library isn't currently compatible with the Android runtime environment."

This link is where I found that answer as well as the error messages you're seeing.

何其悲哀 2024-12-05 06:16:35

我有类似的问题。解决方案应该是将您的 JavaMail 库替换为此处 (适用于 Android 的 JavaMail)。

I had a similar issue. The solution should be to replace your JavaMail libraries with the ones found here (JavaMail for Android).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文