Android: Activity not registered in manifest

<uses-sdk android:minSdkVersion="7" />

<application
    android:description="@string/app_description"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Light" >
    <activity
        android:name="com.xyz.Main.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>
</application>

      

And the Lint tool tells me that my activity is not registered in the manifest, and if I try to start it, LogCat kindly tells me:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.name/com.xyz.Main.MainActivity}: java.lang.ClassNotFoundException: com.xyz.Main.MainActivity

This is driving me crazy, I installed Eclipse again and also updated the SDK and stuff to API level 17 and now I can't seem to execute my own application. I have absolutely no idea what the hell is wrong here, apparently the activity is perfectly registered in the .xml manifest.

Thanks in advance.

+3


source to share


5 answers


I have a solution. I felt motivated enough today to take on this project again and tried to port the project to a Linux distro (which led me to conclude that Linux is a pain in the ass for Android developers) and also to integrate its "line by line" to a new Android project.

I used to implement String and Integer interfaces with specific constants and values ​​(eg 0x00 for "visible"). Unfortunately Android seems to have problems with interfaces and activity classes. Removing the interface and creating static references to constants made the emulator get rid of the problem.



public class MyActivity extends Activity implements Options // [...]
Btn.setVisibility(VISIBLE); // bad idea

public class MyActivity extends Activity // [...]
Btn.setVisibility(Options.VISIBLE); // good idea

      

Hope this helps at least those looking for this problem.

+3


source


Your package name contains an uppercase letter ("Main"), which can be a problem. Check this issue at code.google.com:



http://code.google.com/p/android/issues/detail?id=27529

+4


source


I had the same problem: Lint did not recognize the clearly correct description in AndroidManifest.xml.

Then I changed the package name to one with small letters and dots.

The refactoring scheme in Eclipse did not automatically rename the package name everywhere, so I had to fix a few situations manually, like renaming the package name in the manifest file.

When all parts of the app finally referenced the new package name, Lint was finally satisfied as well.

So only use headers and numbers in package names if you like the problem.

I would like to call this a bug, or at least annoyance, in Lint, as package names should be allowed to follow Java rules.

+1


source


If it does, correct the "package" name (as others have stated), then be sure to run "Android Lint".

The warning will remain until Lint is run after the bug has been fixed.

+1


source


I was getting the same error message, due to a stupid mistake on my part. It took a while to find it, so just in case someone else will make the same mistake and stumble upon this thread, here's what I did wrong:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.DogsDropDown">

    <uses-sdk android:minSdkVersion="7"
              android:targetSdkVersion="14"/>

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name">
    </application>

    <activity
        android:name="com.example.DogsDropDown.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

</manifest>

      

It's obvious when you see it - I've put the <activity> spec outside the <application> spec, not inside it.

0


source







All Articles