小部件 - 无法实例化接收器

Sil*_*vae 5 android widget nullpointerexception

我知道有人问过类似的问题,但没有一个对我有帮助。如果有人向我指出有解决方案的链接,我会非常高兴。无论如何,每次我在 Android 模拟器上安装正在开发的小部件时,我都会收到错误。

错误状态
ERROR/AndroidRuntime(866): java.lang.RuntimeException: 无法实例化接收器 com.ifractal.firstwidget.FirstWidget: java.lang.NullPointerException

这是相关代码

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.ifractal.firstwidget"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver android:name=".FirstWidget" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            <action android:name="android.appwidget.action.APPWIGET_ENABLE" />
        </intent-filter>
        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/provider"
        />
    </receiver>
</application>
Run Code Online (Sandbox Code Playgroud)

这是我在 eclipse 中的项目布局(以显示文件在那里)

我尝试用不同的名称、清洁/建筑和其他一些东西重新创建该项目,但没有任何效果。我感谢您能给我的任何帮助,并愿意在需要时提供更多信息。谢谢。

Mac*_*tle 1

清单对我来说看起来不错。您在 FirstWidget 中获得了 NPE,因此您需要查看该类。检查堆栈跟踪并查看抛出异常的确切位置。可能是构造函数吗?