Search code examples
androidandroid-activitymanifest

Android: Can't find activity in the Manifest, but it IS there?


And i can't figure out why! I checked logcat and i saw that the reason it crashed was because it isn't finding the Activity in the manifest file for some unknown reason.

I've looked at similar threads but none of the answers seem to work for me.

Here's the code where i start the activity:

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);

        Intent ntnt = new Intent(MainActivity.this, SettingsActivity.class);
        startActivity(ntnt);

    }
}

And the manifest file:

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

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MainActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".SettingsActivity"></activity>
    </application>
</manifest>

As you can see i declared the SettingsActivity that i'm trying to start, at the bottom of the Manifest, inside of the tag.

I might be blind, but i can't find anything wrong. Can you?

Let me know if you need more source, but the SettingsActivity should be irrelevant because it doesn't get that var when i run the program.


Source code

If you want to take a closer look, here's the entire source code.

http://www.speedyshare.com/files/30343046/project.zip


Solution

  • The problem is in your SettingsActivity when you are using PreferenceActivity you use

    addPreferencesFromResource(R.layout.settings);
    

    to set contents. but you are using

    setContentView(R.layout.settings);