Abdul Rahman A Samad
Abdul Rahman A Samad

Reputation: 1152

Android Manifest error: Activities not assignable to android.app.activity

So I went to sleep and then when I woke up I opened up my Android project. There is one blaring error all over my Android Manifest file.

All screens in the AndroidManifest show that they are not assignable to 'android.app.activity'

I never had this problem before. Obviously all of my activities are activities and not fragments. (Looking at the answers here, most of it have that kind of error; mistaking fragment for activity)

Also, this Android project has never thrown this kind of error for the past few months.

Right now all of my screens are showing red lines.

Somehow I can run the project just fine even with all those red lines.

Here's what I've tried so far:

  1. Cleaned up the project (Build -> Clean Up)
  2. Rebuild the project (Build -> Rebuild)
  3. Invalidate caches and restart

I'm running the latest Android Studio.

UPDATE:

Here's my Android Manifest:

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

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

        <activity android:name=".MainActivity">

        </activity>
        <activity android:name=".SplashScreen"
            android:screenOrientation="portrait">

            </activity>

        <activity android:name=".ScreenOne"
            android:screenOrientation="portrait">

        </activity>


        <activity android:name=".ScreenTwo"
            android:screenOrientation="portrait">

        </activity>

        <activity android:name=".RegisterActivity"
            android:screenOrientation="portrait">
            </activity>

        <activity android:name=".ScreenThree"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".ScreenFour"
            android:screenOrientation="portrait">
        </activity>

        <activity android:name=".ScreenFive"
            android:screenOrientation="portrait">

        </activity>

        <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:label="@string/app_name" />

        <!--<activity android:name="com.facebook.FacebookActivity"-->
            <!--android:configChanges=-->
                <!--"keyboard|keyboardHidden|screenLayout|screenSize|orientation"-->
            <!--android:theme="@android:style/Theme.Translucent.NoTitleBar"-->
            <!--android:label="@string/app_name" />-->


    </application>

</manifest>

UPDATE 2: The following is the screenshot of the error.

error message

UPDATE 3: When I clicked more, it shows this:

when clicked more

Upvotes: 6

Views: 10829

Answers (3)

Ahamad shimer
Ahamad shimer

Reputation: 1

Go to your activity where your error is occurring. There will be an import in the top which included android.app.Activity. Just clear it and reimport by pressing Alt+Enter.

Upvotes: 0

Umar Ata
Umar Ata

Reputation: 4258

You may follow this to clear these types of errors

  • Close all opened files in editor
  • Then clean or rebuild project
  • Try to create a new project and check whether the same error occurred or not
  • Invalidate Caches and restart android studio (File Menu -> Invalidate Chaches /Restart)

And in the last if all these not got succeeded then delete build folder from your project directory and app directory.

warning - Deleting build will delete your previously generated apk too as well as all the downloaded and extracted dependencies

Upvotes: 1

Sanjeet
Sanjeet

Reputation: 2403

There is no need to give full package name for Activity when declaring in manifest. Just Remove your package name from activity declaration.

<activity name=".ScreenTwo"
          android:screenOrientation="portrait">

Upvotes: -2

Related Questions