简体   繁体   中英

android.content.ActivityNotFoundException ,unable to start activity

I'm trying to make a live wallpaper service, the wallpaper service runs fine but I'm getting this

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

when I try to access it's settings, here's the manifest:

<?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>

and here's the settings activity:

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)
{
}
}

what am I missing ? it says unable to find explicit activity class but I've declared it, so what's wrong?

As far as I can see, android tries to locate your Activity here:

com.miccialabs.liveballwallpaper/com.miccialabs.LiveBallWallpaperSettings

So probably the "package" in your LiveBallWallpaperSettings.java is not correctly defined.

Also you already declared your package ("com.miccialabs.liveballwallpaper"), so for the Activity's name you should use only .ActivityName like this:

<activity 
    android:name=".LiveBallWallpaperSettings"
    android:label="@string/liveWallpaper_settings"
    android:exported="true"
    android:icon="@drawable/ic_launcher">
</activity>

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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