我正在尝试制作动态壁纸服务,壁纸服务运行良好但我得到了这个
03-20 19:13:21.039: E/AndroidRuntime(4147): FATAL EXCEPTION: main
03-20 19:13:21.039: E/AndroidRuntime(4147): java.lang.IllegalStateException: Could not execute method of the activity
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.view.View$1.onClick(View.java:2144)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.view.View.performClick(View.java:2485)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.view.View$PerformClick.run(View.java:9080)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.os.Handler.handleCallback(Handler.java:587)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.os.Handler.dispatchMessage(Handler.java:92)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.os.Looper.loop(Looper.java:130)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.app.ActivityThread.main(ActivityThread.java:3687)
03-20 19:13:21.039: E/AndroidRuntime(4147): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 19:13:21.039: E/AndroidRuntime(4147): at java.lang.reflect.Method.invoke(Method.java:507)
03-20 19:13:21.039: E/AndroidRuntime(4147): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-20 19:13:21.039: E/AndroidRuntime(4147): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-20 19:13:21.039: E/AndroidRuntime(4147): at dalvik.system.NativeStart.main(Native Method)
03-20 19:13:21.039: E/AndroidRuntime(4147): Caused by: java.lang.reflect.InvocationTargetException
03-20 19:13:21.039: E/AndroidRuntime(4147): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 19:13:21.039: E/AndroidRuntime(4147): at java.lang.reflect.Method.invoke(Method.java:507)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.view.View$1.onClick(View.java:2139)
03-20 19:13:21.039: E/AndroidRuntime(4147): ... 11 more
03-20 19:13:21.039: E/AndroidRuntime(4147): Caused by:
android.content.ActivityNotFoundException:
Unable to find explicit activity class {com.miccialabs.liveballwallpaper/com.miccialabs.LiveBallWallpaperSettings};
have you declared this activity in your AndroidManifest.xml?
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.app.Activity.startActivityForResult(Activity.java:2827)
03-20 19:13:21.039: E/AndroidRuntime(4147): at android.app.Activity.startActivity(Activity.java:2933)
03-20 19:13:21.039: E/AndroidRuntime(4147): at com.android.wallpaper.livepicker.LiveWallpaperPreview.configureLiveWallpaper(LiveWallpaperPreview.java:125)
03-20 19:13:21.039: E/AndroidRuntime(4147): ... 14 more
03-20 19:13:21.046: E/(1516): Dumpstate > /data/log/dumpstate_app_error
当我尝试访问它的设置时, 这是清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.miccialabs.liveballwallpaper"
android:versionName="1"
android:versionCode="1">
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<activity
android:name="com.miccialabs.liveballwallpaper.LiveBallWallpaperSettings"
android:label="@string/liveWallpaper_settings"
android:exported="true"
android:icon="@drawable/ic_launcher">
</activity>
<service android:name="com.miccialabs.liveballwallpaper.BallLiveWallpaper"
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data android:name="android.service.wallpaper"
android:resource="@xml/livewallpaper" />
</service>
</application>
这是设置活动:
package com.miccialabs.liveballwallpaper;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class LiveBallWallpaperSettings extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener
{
@Override
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
getPreferenceManager().setSharedPreferencesName(com.miccialabs.liveballwallpaper.BallLiveWallpaper.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.livewallpaper_settings);
getPreferenceManager().getSharedPreferences()
.registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onResume()
{
super.onResume();
}
@Override
protected void onDestroy()
{
getPreferenceManager().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
super.onDestroy();
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key)
{
}
}
我错过了什么?它说无法找到明确的活动类,但我已经宣布了,所以出了什么问题?
答案 0 :(得分:0)
据我所见,android尝试在此处找到您的活动:
com.miccialabs.liveballwallpaper/com.miccialabs.LiveBallWallpaperSettings
所以可能是&#34;包&#34;在您的LiveBallWallpaperSettings.java中未正确定义。
此外,您已经宣布了您的包裹(&#34; com.miccialabs.liveballwallpaper&#34;),因此对于活动的名称,您应该只使用.ActivityName,如下所示:
<activity
android:name=".LiveBallWallpaperSettings"
android:label="@string/liveWallpaper_settings"
android:exported="true"
android:icon="@drawable/ic_launcher">
</activity>
希望它有所帮助。