简体   繁体   English

当我运行googlecast示例时,Android ClassNotFoundException

[英]Android ClassNotFoundException when I run googlecast sample

10-24 22:37:47.926: E/Trace(31760): error opening trace file: No such file or directory (2)
10-24 21:50:17.726: E/AndroidRuntime(25669): FATAL EXCEPTION: main
10-24 21:50:17.726: E/AndroidRuntime(25669): java.lang.RuntimeException: Unable to       instantiate activity     ComponentInfo{com.example.castsample/com.example.castsample.CastSampleActivity}: java.lang.ClassNotFoundException: com.example.castsample.CastSampleActivity
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.os.Looper.loop(Looper.java:137)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.ActivityThread.main(ActivityThread.java:4745)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at java.lang.reflect.Method.invokeNative(Native Method)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at java.lang.reflect.Method.invoke(Method.java:511)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at dalvik.system.NativeStart.main(Native Method)
10-24 21:50:17.726: E/AndroidRuntime(25669): Caused by: java.lang.ClassNotFoundException: com.example.castsample.CastSampleActivity
10-24 21:50:17.726: E/AndroidRuntime(25669):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
10-24 21:50:17.726: E/AndroidRuntime(25669):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
10-24 21:50:17.726: E/AndroidRuntime(25669):    ... 11 more    </code>

This is the error what I encountered when running google-cast sample. 这是我在运行google-cast示例时遇到的错误。 And I don't modify any thing in Manifest. 而且我不修改清单中的任何内容。
Any helps will be appreciated. 任何帮助将不胜感激。

put your libraries/jar inside libs folder. 将您的库/罐子放在libs文件夹中。 if it is still named lib, rename it to libs. 如果仍将其命名为lib,则将其重命名为libs。

Try the following steps in Android project: 请在Android项目中尝试以下步骤:

  • Click mouse right button on the project in "Project Explorer", then select "Properties" 在“项目资源管理器”中的项目上单击鼠标右键,然后选择“属性”
  • Select "Java Build Path" in the list at left. 在左侧列表中选择“ Java构建路径”。
  • Make click on "Order and Export" tab. 单击“订购和出口”标签。
  • Mark the two checkboxes for "Android Private Libraries" and "Android Dependencies", respectively, then click OK button. 分别标记“ Android Private Libraries”和“ Android Dependencies”两个复选框,然后单击“确定”按钮。
  • Clean project(s) and run. 清理项目并运行。

If nothing works, you might want to try some solutions from this page . 如果没有任何效果,则可能需要尝试从此页面尝试一些解决方案。 Here is the most voted answer: https://stackoverflow.com/a/11776806/827110 这是投票率最高的答案: https : //stackoverflow.com/a/11776806/827110

Putting v7-appcompat.jar, v7-mediarouter.jar doesn't solve the problem. 放置v7-appcompat.jar,v7-mediarouter.jar不能解决问题。 It will get error in run time. 它将在运行时错误。
You must import 2 above project as library project. 您必须将上述2个项目导入为库项目。 Appcompat is dependency project of Mediarouter project. Appcompat是Mediarouter项目的依赖项目。 Then add 2 above project as dependency project of your project. 然后在项目上方添加2个项目作为依赖项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM