无法运行Android Chromecast示例

时间:2014-10-19 13:06:55

标签: java android chromecast eclipse-adt

我正在尝试运行" democastplayer" Android中的示例(与tic tac toe相同)当我在手机上运行时它似乎失败了。错误很明显,但我不知道是什么导致它。我的项目编译得很好但是当它运行时我得到了类找不到错误。我使用以下方法在eclipse中包含了appcompat_v7,android-support-v7-mediarouter和google-play-services-lib项目。

http://developer.android.com/tools/support-library/setup.html

FWIW - 我正在使用build 21编译,在64位ubuntu上进行开发,我的hello world示例运行得很好。

任何帮助都将不胜感激。

10-19 06:59:41.702: E/AndroidRuntime(22076): FATAL EXCEPTION: main
10-19 06:59:41.702: E/AndroidRuntime(22076): Process: com.google.android.gms.cast.samples.democastplayer, PID: 22076
10-19 06:59:41.702: E/AndroidRuntime(22076): java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/app/ActivityManagerCompat;
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.support.v7.media.MediaRouter$GlobalMediaRouter.<init>(MediaRouter.java:1528)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.support.v7.media.MediaRouter.getInstance(MediaRouter.java:220)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at com.google.android.gms.cast.samples.democastplayer.BaseCastPlayerActivity.onCreate(BaseCastPlayerActivity.java:182)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at com.google.android.gms.cast.samples.democastplayer.SdkCastPlayerActivity.onCreate(SdkCastPlayerActivity.java:51)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.Activity.performCreate(Activity.java:5933)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.ActivityThread.access$800(ActivityThread.java:144)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.os.Handler.dispatchMessage(Handler.java:102)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.os.Looper.loop(Looper.java:135)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at android.app.ActivityThread.main(ActivityThread.java:5221)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at java.lang.reflect.Method.invoke(Native Method)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at java.lang.reflect.Method.invoke(Method.java:372)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
10-19 06:59:41.702: E/AndroidRuntime(22076): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.app.ActivityManagerCompat" on path: DexPathList[[zip file "/data/app/com.google.android.gms.cast.samples.democastplayer-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
10-19 06:59:41.702: E/AndroidRuntime(22076):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
10-19 06:59:41.702: E/AndroidRuntime(22076):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
10-19 06:59:41.702: E/AndroidRuntime(22076):    ... 17 more
10-19 06:59:41.702: E/AndroidRuntime(22076):    Suppressed: java.lang.ClassNotFoundException: android.support.v4.app.ActivityManagerCompat
10-19 06:59:41.702: E/AndroidRuntime(22076):        at java.lang.Class.classForName(Native Method)
10-19 06:59:41.702: E/AndroidRuntime(22076):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
10-19 06:59:41.702: E/AndroidRuntime(22076):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
10-19 06:59:41.702: E/AndroidRuntime(22076):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
10-19 06:59:41.702: E/AndroidRuntime(22076):        ... 18 more
10-19 06:59:41.702: E/AndroidRuntime(22076):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

2 个答案:

答案 0 :(得分:0)

嗯。转到v4 / support jar的父lib的'project.props'文件。

审核'referencing a lib project'

这个parenet lib应该在你的主项目中提到lib.pros并尝试修改子项以包含v4 / support(下面的样本类型

target=android-19
android.library=true
android.library.reference.1=../../../../usr/local/src/android-sdk-linux/extras/android/support/v7/appcompat
android.library.reference.2=../../../../usr/local/src/android-sdk-linux/extras/android/support/v7/mediarouter
android.library.reference.3=../../../../usr/local/src/android-sdk-linux/extras/google/google_play_services/libproject/google-play-services_lib

答案 1 :(得分:0)

有两个不同的v4.jar,appcompat_v7中的v4.jar没有包含ActivityManagerCompat类,所以应该将sdk \ extras \ android \ support \ v4中的v4.jar替换为appcompat_v7 lib。