NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager [英] NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager

查看:24
本文介绍了NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 平台:MonoDroid v4.2.4
  • IDE:Visual Studio 2012
  • 最低 SDK 版本:API 12

我在尝试使用包含在 Android.Support.v4.Content 命名空间中的 LocalBroadcastManager 类时遇到运行时问题.在我的 IDE 中,我已经明确添加了引用并且可以很好地限定命名空间/类的范围,并且在编写一些代码后,按预期编译.但是,在应用程序部署和启动时,我收到错误提示:"NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager"

I'm having runtime issues when trying to utilize the LocalBroadcastManager class included in the Android.Support.v4.Content namespace. In my IDE, I've explicitly added the reference and can scope the namespace/class fine, and, after writing some code, compiles as expected. However, upon application deployment and launch, I'm prompted with the error: "NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager"

这里是提示运行时错误的代码(DSC_Discconected_From_Device是一个继承自BroadcastReceiver的类).它在最后一行停止执行.

Here's the code that prompts the runtime error (DSC_Discconected_From_Device is a class that inherits from BroadcastReceiver). It stops execution at the last line.

        IntentFilter filter = new IntentFilter(UsbManager.ActionUsbDeviceDetached);

        DSC_Disconnected_From_Device Receiver = new DSC_Disconnected_From_Device();

        LocalBroadcastManager.GetInstance(this).RegisterReceiver(Receiver, filter);

SDK 管理器下安装了所有的 API 包,以及 extras 下的Support Library"包.

Under the SDK manager, all the API packages are installed, as well as the "Support Library" package under extras.

它在哪里寻找类的定义?我大概已经将源 LocalBroadcastManager.java 复制到 android-sdk 框架中它可能"正在查找的路径中.例如:..android-sdkextrasandroidsupportv4srchoneycombandroidsupportv4contentLocalBroadcastManager.java

Where is it looking for the definition of the class? I've presumably copied the source, LocalBroadcastManager.java, to paths in the android-sdk framework where it "might" be looking. For example: ..android-sdkextrasandroidsupportv4srchoneycombandroidsupportv4contentLocalBroadcastManager.java

想法?

忘记提及我的项目已经在位于我项目根目录的文件夹libs"中引用了支持库 android-support-v4.我必须创建目录并通过 Visual Studio 添加它.

Forgot to mention that my project already references the support library, android-support-v4, in the folder "libs", located in the root of my project. I had to create the directory and add it through Visual Studio.

推荐答案

问题似乎与android-support-v4.jar库的属性"有关.

The problem seems to be related to the "properties" of the android-support-v4.jar library.

默认情况下,Visual Studio 的高级属性中列出的构建操作"的值为 Content.我将值切换到 AndroidJavaLibrary 并且运行时错误消失了.

By default, the "Build Action" listed in the Advanced Properties in Visual Studio had a value of Content. I switched the value to AndroidJavaLibrary and the runtime error has disappeared.

但是,BroadcastReceiver 没有接收到 USB 断开连接意图,嗯...将相应地更新此答案.

However, the BroadcastReceiver isn't receiving the USB disconnect intent, hmm... Will update this answer accordingly.

我永远无法让 LocalBroadcastReceiver 工作,所以我不得不使用常规的.

I could never get a LocalBroadcastReceiver to work, so I had to use a regular one.

这篇关于NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆