Activity is not assignable to Activity

Your PlanMeMainActivity isn't an Activity; it's a Fragment. Your activity needs to be an activity, and you can then add fragments to it.


Clean Project solved this error. The root cause of the error in my case was different, but I got the same "Activity is not assignable to Activity" error.

I faced this problem after copying existing (perfectly working) Android Project to create a new one. After copying the project, the AppCompatActivity was not recognized causing all the activities in the Android Manifest file to show the error "activity-is-not-assignable-to-activity".
Which was solved by cleaning the project.


Change this line

public class PlanMeMainActivity extends Fragment {

to

public class PlanMeMainActivity extends FragmentActivity {

Here you can find all that you need to know about Activities and even more. Cheers


Where are you wrong?

  <activity
          android:name="com.pctoolman.planme.app.PlanMeMainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Why are you wrong?

The mistake is that you added the Fragment in the Manifest as Activity. However Fragments are not activities

What you should do?

You should add the fragment in an activity and then define that activity in the Manifest

Tags:

Java

Android