Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Activity not registered in the 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 isn't registered in the manifest and if I try to run 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 nuts, I've re-installed Eclipse as well as updated the SDK and stuff to API-level 17 and now I seem to be unable to execute my very own app. I've got absolutely no idea what the hell's wrong here, apparently the activity is perfectly well registered within the manifest.xml.

Thanks in advance.

like image 594
chollinger Avatar asked Mar 24 '12 15:03

chollinger


3 Answers

Your package name contains a capital letter ("Main"), that might be a problem. Check out this issue on code.google.com:

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

like image 86
soren.qvist Avatar answered Sep 27 '22 17:09

soren.qvist


I've got the solution. Today I felt motivated enough get my hands on this project again and tried to port the project to a Linux-distribution (which led me to the conclusion that Linux is a pain in the ass for Android developent) as well as to integrate it "line by line" to a new Android project.

I used to implement String- & Integer-interfaces with certain constants and values (e.g. 0x00 for "visible"). Unfortunately, Android seems to have trouble with interfaces and activity-classes. Removing the interface and making static references onto the 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

Hopefully this is gonna help at least someone searching for this issue.

like image 22
chollinger Avatar answered Sep 27 '22 16:09

chollinger


If this happens, correct the "package" name (as others have stated) then be sure to re-run "Android Lint".

The warning will stay until Lint has been run again after the correcting the error.

like image 44
Tigger Avatar answered Sep 27 '22 18:09

Tigger