Bran
Bran

Reputation: 19

Unsure how to correctly edit my AndroidManifest.xml when creating a new class

I'm currently building my first Android app using Java. I am trying to add a class to my app called Pop.java that displays a pop up message. However, when compiling its telling me my configuration is incorrect and I am getting an "AndroidManifest.xml does exist of has incorrect root tag" error. When looking it up it seems like I need to update my .xml file to add this .Pop class. Here is what I'm trying right now thats still giving me errors:

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

    <activity
        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/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        </activity> android:name=".Pop" ></activity>
    </application>
</manifest>

The only part I edited of this .xml file was

</activity> android:name=".Pop" ></activity>

Any help on where I'm going wrong would be greatly appreciated!!

Upvotes: 1

Views: 336

Answers (2)

Ronak Sethi
Ronak Sethi

Reputation: 627

Just do some correction to the AndroidManifest.xml:

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

  <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/AppTheme">

    <activity android:name=".Pop"/> <!--here is your activity, you wanna add!-->
    <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: 1

jobernas
jobernas

Reputation: 694

Your first two Tags are wrong!

Open manifest and application. For each tag you open you need to close. Also New Activities live inside application tag.

Also you are opening a new tag for activity wrongly

</activity> android:name=".Pop" ></activity>

Should be

<activity android:name=".Pop" ></activity>

The Manifest fixed bellow

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

    <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/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name=".Pop" ></activity>
    </application>
</manifest>

Upvotes: 1

Related Questions