neoshadybeat
neoshadybeat

Reputation: 51

Activity not found with AndroidAnnotations

Hi i've added the AndroidAnnotations and configured it; it generates the activity with the underscore _ as suffix, but when I try to lunch the app, it gives this error

   05-26 04:17:23.524: E/AndroidRuntime(5096): java.lang.RuntimeException: 
   Unable to instantiate activity
   ComponentInfo{android_app.candgo/android_app.candgo.HelloAndroidActivity_}:  
   java.lang.ClassNotFoundException: Didn't find class
   "android_app.candgo.HelloAndroidActivity_"    
   on path: /data/app/android_app.candgo-1.apk

Any suggestion about why it doesn't work

PD: I've ADT v22 PD: I've the HelloAndroidActivity_ registered at manifest

This is my manifest.xml (sorry for the delay)

  <uses-sdk android:minSdkVersion="8"
            android:targetSdkVersion="16" />

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

Upvotes: 5

Views: 3245

Answers (4)

Sonu Kumar
Sonu Kumar

Reputation: 969

If you are using Eclipse follow these steps :

Step 1. Go to Java Compiler and make sure that Compiler compliance level is set to 1.6, otherwise the processor won't be activated

Step 2. Go to Java Compiler > Annotation Processing and choose Enable annotation processing

step 3. Go to Java Compiler > Annotation Processing > Factory Path and add the processor JAR : androidannotations-X.X.X.jar.

step 4 Confirm the workspace rebuild

Upvotes: 0

Karim Varela
Karim Varela

Reputation: 7652

You need to add the ".apt_generated", or whichever folder AA outputs to, to your source directories listing. In Android Studio, you can find this in Project Settings -> Modules -> module_in_question -> Sources

Upvotes: 3

develop.lou
develop.lou

Reputation: 1

you need to register the activity class(AndroidAnnotations) in your manifest.xml,like: <activity android:name = "com.your.packageName" android:screenOrientation="portrait" android:configChanges = "orientation"/>
then you can use it.

Upvotes: 0

Raghunandan
Raghunandan

Reputation: 133560

Check your manifest file for a entry of the activity. Check the name.

If you updated ADT to rev 22. you can try this java.lang.ClassNotFoundException after changing nothing in the project but upgrading eclipse android sdk.

Check the package name in manifest

    <manifest package="com.example.mypackaganame" //check the name

Check under application tag for the activity entry

    <activity
        android:name="com.example.mypackaganame.MainActivity"
        // this is the main activity
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>  

Say you have second Activity. This how you declare for implicit intents

     <activity
        android:name="com.example.mypackaganame.SecondActivity"
        // this is the Second activity
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.mypackaganame.SecondActivity" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>           

Foe explicit intents

      <activity
        android:name=".SecondActivity"
        // this is the Second activity
        android:label="@string/app_name" >
    </activity>           

Upvotes: 0

Related Questions