NoClassDefFoundError的:安卓/支持/ V4 /内容/ LocalBroadcastManager [英] NoClassDefFoundError: android/support/v4/content/LocalBroadcastManager

查看:712
本文介绍了NoClassDefFoundError的:安卓/支持/ V4 /内容/ LocalBroadcastManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我想利用包含在Android.Support.v4.Content命名空间中的LocalBroadcastManager类时,其运行时的问题。在我的IDE,我已经明确添加的参考,并不能适用范围的命名空间/类精细,并写一些code后,编译如预期。然而,在应用程序部署和启动,我提示错误:的NoClassDefFoundError:安卓/支持/ V4 /内容/ 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"

这里的code,提示运行时错误(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包安装,以及支持库包下的群众演员。

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

它在哪里寻找类的定义?我presumably复制源,LocalBroadcastManager.java,为路径在Android的SDK框架,它可能会寻找。例如: ..\android-sdk\extras\android\support\v4\src\honeycomb\android\support\v4\content\LocalBroadcastManager.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-sdk\extras\android\support\v4\src\honeycomb\android\support\v4\content\LocalBroadcastManager.java

想法?

编辑:忘了提,我的项目已经引用了支持库,Android的支持-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的支持 - v4.jar库的属性。

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

默认情况下,构建行动,在Visual Studio中的高级属性中列出了值的内容的。我切换值的 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的:安卓/支持/ V4 /内容/ LocalBroadcastManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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