无法将MediaRouteButton编译成项目

时间:2017-06-12 06:22:41

标签: chromecast mediarouter

我正在使用CastButton进行Movie项目,我完成了一个样本,这非常有效。但是,当我在真正的项目中做我有一个问题。 我将编译导入我的grande文件,但是当我创建MediaRouteButton时,我遇到了错误,我尝试了很多方法,但我无法修复它,所以我现在真的需要帮助: 这是:编译文件:

compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:mediarouter-v7:25.0.0'
    compile 'com.googlecode.android-query:android-query:0.25.9'
    compile 'com.google.android.gms:play-services-cast-framework:10.2.0'

这是logcat:

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/MediaRouteButton;
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView.addMediaButton(MediaPlayerView.java:533)
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView.access$4200(MediaPlayerView.java:53)
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView$3.run(MediaPlayerView.java:514)
                                                   at android.app.Activity.runOnUiThread(Activity.java:5524)
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView.preload(MediaPlayerView.java:490)
                                                   at com.jlabs.pluginplayer.PlayerActivity.onResume(PlayerActivity.java:330)
                                                   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258)
                                                   at android.app.Activity.performResume(Activity.java:6327)
                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092)
                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134)
                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                   at android.os.Looper.loop(Looper.java:148)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.MediaRouteButton" on path: DexPathList[[zip file "/data/app/jp.tsutayamovie-1/base.apk"],nativeLibraryDirectories=[/data/app/jp.tsutayamovie-1/lib/arm, /data/app/jp.tsutayamovie-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
                                                   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView.addMediaButton(MediaPlayerView.java:533) 
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView.access$4200(MediaPlayerView.java:53) 
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView$3.run(MediaPlayerView.java:514) 
                                                   at android.app.Activity.runOnUiThread(Activity.java:5524) 
                                                   at com.jlabs.pluginplayer.view.MediaPlayerView.preload(MediaPlayerView.java:490) 
                                                   at com.jlabs.pluginplayer.PlayerActivity.onResume(PlayerActivity.java:330) 
                                                   at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258) 
                                                   at android.app.Activity.performResume(Activity.java:6327) 
                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3092) 
                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) 
                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481) 
                                                   at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                   at android.os.Looper.loop(Looper.java:148) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                Suppressed: java.lang.ClassNotFoundException: android.support.v7.app.MediaRouteButton
                                                   at java.lang.Class.classForName(Native Method)
                                                   at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                   at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                   at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                        ... 20 more
                                                Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我该如何解决?

1 个答案:

答案 0 :(得分:0)

基于此thread,您会收到该错误,原因如下:

  

在您的gradle构建文件中,也许您的应用程序正在定位并使用仍处于开发阶段的Android测试版进行编译:

compileSdkVersion 'android-L'
buildToolsVersion '20'
     

以及

minSdkVersion 20
targetSdkVersion 20
     

首先要注意的是,在没有安装android-L的任何设备上,此应用程序将无法正常运行(此时)。

其他参考:java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/os/BuildCompat

  

检查你的类路径是否包含那个jar(AppCompat),如果你的类路径没有包含jar,那么只需在你的类路径中添加该类。

希望这有帮助!