Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 621
Abdul Rahman A Samad Avatar asked Oct 29 '16 10:10

Abdul Rahman A Samad


People also ask

How do I add an activity to a manifest file?

To declare your activity, open your manifest file and add an <activity> element as a child of the <application> element. For example: <manifest ... > The only required attribute for this element is android:name, which specifies the class name of the activity.

Why do we have to declare activities in manifest file?

Because it lets you define the structure and metadata of your android application and its components.

What is android manifest permission?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.


1 Answers

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

like image 60
Umar Ata Avatar answered Sep 28 '22 08:09

Umar Ata