AndroidGoogleCast错误——.lang。NoClassDefFoundError:android.support.v7.media.MediaRouterGlobalMediaRouter - Android GoogleCast Error - java.lang.NoClassDefFoundError: android.support.v7.media.MediaRouterGlobalMediaRouter

- 此内容更新于:2016-02-18
主题:

我编译ChromeCast这CastVideos-androidGithub项目。在Eclipse环境中。我安装了最新的依赖项目。当我运行项目,它抛出运行时错误。

原文:

Im compiling ChromeCast this Github Project CastVideos-android.in Eclipse environment.I have latest dependencies installed on the project.

enter image description here enter image description here

When i running the project,its throws this run time error.

   05-05 11:25:08.353: E/AndroidRuntime(17660): FATAL EXCEPTION: main
   05-05 11:25:08.353: E/AndroidRuntime(17660): java.lang.NoClassDefFoundError: android.support.v7.media.MediaRouter$GlobalMediaRouter$1
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.support.v7.media.MediaRouter$GlobalMediaRouter.<init>(MediaRouter.java:1628)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.support.v7.media.MediaRouter.getInstance(MediaRouter.java:246)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at com.google.android.libraries.cast.companionlibrary.cast.BaseCastManager.<init>(BaseCastManager.java:189)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.<init>(VideoCastManager.java:196)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.initialize(VideoCastManager.java:223)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at com.google.sample.cast.refplayer.CastApplication.onCreate(CastApplication.java:43)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4280)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.app.ActivityThread.access$1400(ActivityThread.java:143)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.os.Handler.dispatchMessage(Handler.java:99)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.os.Looper.loop(Looper.java:137)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at android.app.ActivityThread.main(ActivityThread.java:4950)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at java.lang.reflect.Method.invokeNative(Native Method)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at java.lang.reflect.Method.invoke(Method.java:511)
   05-05 11:25:08.353: E/AndroidRuntime(17660):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:997)


   05-05 11:25:08.303: E/dalvikvm(17660): Could not find class 'android.support.v7.media.MediaRouter$GlobalMediaRouter$1', referenced from method android.support.v7.media.MediaRouter$GlobalMediaRouter.<init>
   05-05 11:25:08.303: W/dalvikvm(17660): VFY: unable to resolve new-instance 1180 (Landroid/support/v7/media/MediaRouter$GlobalMediaRouter$1;) in Landroid/support/v7/media/MediaRouter$GlobalMediaRouter;
   05-05 11:25:08.303: D/dalvikvm(17660): VFY: replacing opcode 0x22 at 0x0035
   05-05 11:25:08.303: W/dalvikvm(17660): VFY: unable to find class referenced in signature (Landroid/support/v4/media/session/MediaSessionCompat;)
   05-05 11:25:08.313: I/dalvikvm(17660): Could not find method android.support.v4.media.session.MediaSessionCompat.getSessionToken, referenced from method android.support.v7.media.MediaRouter$GlobalMediaRouter.getMediaSessionToken
   05-05 11:25:08.313: W/dalvikvm(17660): VFY: unable to resolve virtual method 2967: Landroid/support/v4/media/session/MediaSessionCompat;.getSessionToken ()Landroid/support/v4/media/session/MediaSessionCompat$Token;
   05-05 11:25:08.313: D/dalvikvm(17660): VFY: replacing opcode 0x6e at 0x0011
   05-05 11:25:08.323: W/dalvikvm(17660): VFY: unable to find class referenced in signature (Landroid/support/v4/media/session/MediaSessionCompat;)
   05-05 11:25:08.323: I/dalvikvm(17660): Could not find method android.support.v4.media.session.MediaSessionCompat.getRemoteControlClient, referenced from method android.support.v7.media.MediaRouter$GlobalMediaRouter.setMediaSessionCompat
   05-05 11:25:08.323: W/dalvikvm(17660): VFY: unable to resolve virtual method 2966: Landroid/support/v4/media/session/MediaSessionCompat;.getRemoteControlClient ()Ljava/lang/Object;
   05-05 11:25:08.323: D/dalvikvm(17660): VFY: replacing opcode 0x6e at 0x000a
   05-05 11:25:08.323: I/dalvikvm(17660): Could not find method android.support.v4.media.session.MediaSessionCompat.getMediaSession, referenced from method android.support.v7.media.MediaRouter$GlobalMediaRouter.setMediaSessionCompat
   05-05 11:25:08.323: W/dalvikvm(17660): VFY: unable to resolve virtual method 2965: Landroid/support/v4/media/session/MediaSessionCompat;.getMediaSession ()Ljava/lang/Object;
   05-05 11:25:08.323: D/dalvikvm(17660): VFY: replacing opcode 0x6e at 0x001e
   05-05 11:25:08.333: I/dalvikvm(17660): Could not find method android.support.v4.media.session.MediaSessionCompat.getRemoteControlClient, referenced from method android.support.v7.media.MediaRouter$GlobalMediaRouter.setMediaSessionCompat
   05-05 11:25:08.333: W/dalvikvm(17660): VFY: unable to resolve virtual method 2966: Landroid/support/v4/media/session/MediaSessionCompat;.getRemoteControlClient ()Ljava/lang/Object;
   05-05 11:25:08.333: D/dalvikvm(17660): VFY: replacing opcode 0x6e at 0x0032
   05-05 11:25:08.333: I/dalvikvm(17660): Could not find method android.support.v4.media.session.MediaSessionCompat.addOnActiveChangeListener, referenced from method android.support.v7.media.MediaRouter$GlobalMediaRouter.setMediaSessionCompat
   05-05 11:25:08.333: W/dalvikvm(17660): VFY: unable to resolve virtual method 2964: Landroid/support/v4/media/session/MediaSessionCompat;.addOnActiveChangeListener (Landroid/support/v4/media/session/MediaSessionCompat$OnActiveChangeListener;)V
   05-05 11:25:08.333: D/dalvikvm(17660): VFY: replacing opcode 0x6e at 0x0044
   05-05 11:25:08.333: I/dalvikvm(17660): Failed resolving Landroid/support/v7/media/MediaRouter$GlobalMediaRouter$1; interface 510 'Landroid/support/v4/media/session/MediaSessionCompat$OnActiveChangeListener;'
   05-05 11:25:08.333: W/dalvikvm(17660): Link of class 'Landroid/support/v7/media/MediaRouter$GlobalMediaRouter$1;' failed

enter image description here

enter image description here

网友:检查。特别是部分如果你的检查

(原文:Check buildpath. Specifically Order and Export section if your support library is checked)

楼主:没有选项选择支持库。请看屏幕截图

(原文:there is no option to select support Libraries ..please see the screen shot)

网友:当我说,我的意思

(原文:When i say support library, i mean v7-appcompat library)

楼主:哦,是的..我很抱歉。

(原文:oh yes..im sorry.)

网友:从错误中我看到你的项目包含多个。一个是在您的项目中,另一个是在图书馆,你在您的项目中添加。只删除一个图书馆,你在您的项目中添加。然后清洁和运行您的应用程序。

(原文:From the error i see that that your project contains multiple support-v7 library. One is in your project and another is in the library which you have added in your project. Just remove the one library which you have added in your project. And then clean and run your application.)

解决方案:
去您的项目和检查文件。右键单击它并检查。特别部分如果你检查检查如果您的项目包含多个。一个是在您的项目中,另一个是在图书馆,你在您的项目中添加。只删除一个图书馆,你在您的项目中添加。然后清洁和运行您的应用程序。
原文:
  1. Go to your projects and check for v7-appcompat jar file. Right click on it and Build Path-> Add to Buildpath

  2. Check buildpath. Specifically Order and Export section if your v7-appcompat library is checked

  3. Check if your project contains multiple support-v7 library. One is in your project and another is in the library which you have added in your project. Just remove the one library which you have added in your project. And then clean and run your application.