2017-06-12 106 views
0

我正在使用CastButton執行Movie項目,我完成了一個示例,此工作非常完美。但是當我在做真正的項目時,我遇到了一個問題。 我導入編譯到我的grande文件中,但是當我創建MediaRouteButton時我有錯誤,我嘗試了很多方法,但無法修復,所以現在我真的需要幫助: 這是:編譯文件:無法將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 

我怎樣才能解決呢?

回答

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

檢查你的classpath中包含的jar(程序兼容性),如果你的classpath中不包含JAR然後只需添加類在類路徑中。

希望這會有所幫助!

+0

compileSdkVersion 23 buildToolsVersion 「25.0.3」 minSdkVersion.apiLevel 18 targetSdkVersion.apiLevel 23 我用它 –