最近我无法运行任何适用于 Android 的 YouTube API 演示。在实例化第一个对 YouTube API 类有一定依赖性的活动时,我得到了 ClassNotFoundException。任何使用 YouTube API 的应用都会发生这种情况。
我的 YouTube 应用已更新到 4.5.+,我正在三星 Galaxy s3 mini 上运行 JellyBean。
我的手机或 Eclipse 中是否缺少任何设置?
[编辑] 这是 logcat 副本(这次在 Nexus S 上运行):
06-18 09:45:26.796: D/libEGL(15140): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
06-18 09:45:26.832: D/libEGL(15140): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
06-18 09:45:26.836: D/libEGL(15140): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
06-18 09:45:26.964: D/OpenGLRenderer(15140): Enabling debug mode 0
06-18 09:45:35.796: W/dalvikvm(15140): Unable to resolve superclass of Lcom/examples/youtubeapidemo/YouTubeFailureRecoveryActivity; (109)
06-18 09:45:35.796: W/dalvikvm(15140): Link of class 'Lcom/examples/youtubeapidemo/YouTubeFailureRecoveryActivity;' failed
06-18 09:45:35.804: W/dalvikvm(15140): Unable to resolve superclass of Lcom/examples/youtubeapidemo/PlayerViewDemoActivity; (102)
06-18 09:45:35.804: W/dalvikvm(15140): Link of class 'Lcom/examples/youtubeapidemo/PlayerViewDemoActivity;' failed
06-18 09:45:35.820: D/AndroidRuntime(15140): Shutting down VM
06-18 09:45:35.820: W/dalvikvm(15140): threadid=1: thread exiting with uncaught exception (group=0x41a1a300)
06-18 09:45:35.855: E/AndroidRuntime(15140): FATAL EXCEPTION: main
06-18 09:45:35.855: E/AndroidRuntime(15140): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.examples.youtubeapidemo/com.examples.youtubeapidemo.PlayerViewDemoActivity}: java.lang.ClassNotFoundException: com.examples.youtubeapidemo.PlayerViewDemoActivity
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.ActivityThread.access$600(ActivityThread.java:130)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.os.Handler.dispatchMessage(Handler.java:99)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.os.Looper.loop(Looper.java:137)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.ActivityThread.main(ActivityThread.java:4745)
06-18 09:45:35.855: E/AndroidRuntime(15140): at java.lang.reflect.Method.invokeNative(Native Method)
06-18 09:45:35.855: E/AndroidRuntime(15140): at java.lang.reflect.Method.invoke(Method.java:511)
06-18 09:45:35.855: E/AndroidRuntime(15140): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
06-18 09:45:35.855: E/AndroidRuntime(15140): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-18 09:45:35.855: E/AndroidRuntime(15140): at dalvik.system.NativeStart.main(Native Method)
06-18 09:45:35.855: E/AndroidRuntime(15140): Caused by: java.lang.ClassNotFoundException: com.examples.youtubeapidemo.PlayerViewDemoActivity
06-18 09:45:35.855: E/AndroidRuntime(15140): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-18 09:45:35.855: E/AndroidRuntime(15140): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-18 09:45:35.855: E/AndroidRuntime(15140): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
06-18 09:45:35.855: E/AndroidRuntime(15140): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
06-18 09:45:35.855: E/AndroidRuntime(15140): ... 11 more
[解决了!]
酷我找到了答案。似乎是后期 ADT 更新中的错误。此链接说明了一切:https ://groups.google.com/d/msg/adt-dev/epOfZbKPFdk/v4a-pTbq1OwJ
或者引用它:
项目右键 > 属性 > Java 构建路径 > 订购和导出 > 检查 Android 私有库 > 确定
然后项目>清理...
并重建/运行。