Home > database >  The activity 'MainActivity' is not declared in activity_main.xml
The activity 'MainActivity' is not declared in activity_main.xml

Time:01-04

This is AndroidManifest.xml & you can see the errors down below

This is what error i'm getting while run.

It was working completely fine till now, I restart the pc, after that i opened android studio and find that main activity is not declared in activity_main.xml asking me to create a class while id didn't change anything

CodePudding user response:

The MainActivity is not included inside the <application/> tag of the manifest.

You can replace the code inside the AndroidManifest.xml with this one and it should work. :)

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.TipTime">

        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.TipTime">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

    </application>

</manifest>

CodePudding user response:

From the Build menu, try Clean Project and then Rebuild Project

  •  Tags:  
  • Related