Problems with Android Manifest

2

I get the following error:

 android.content.ActivityNotFoundException: Unable to find explicit activity class {montsemkd.eac1_activity/montsemkd.eac1_activity.Acitivty2}; have you declared this activity in your AndroidManifest.xml?

I'm trying something as simple as going from one Activity to another through a button.

Mi manifest es el siguiente:

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

    <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>


    </application>

</manifest>

Can you help me to understand what I have to put in the manifest to avoid problems?

The main class is MainActivity with its interface: activity_main.

And the second screen is Activity2 with its interface: screen2

thank you very much !!

    
asked by Montse Mkd 20.09.2018 в 22:55
source

1 answer

3

It is not a problem that you declare different layouts in each Activity

  

You help me understand that I have to put in the manifest to not have   problems?

     

The main class is MainActivity with its interface: activity_main.

     

And the second screen is Activity2 with its interface: screen2

But check the name, in reality your Activity is called Acitivty2 and not Activity2 .

  

ActivityNotFoundException: Unable to find explicit activity class   {montsemkd.eac1_activity / montsemkd.eac1_activity.Acitivty2}; have you   declared this activity in your AndroidManifest.xml?

You must declare the Activities that are used in your application within your file AndroidManifest.xml , in this case you must declare the activity of name Acitivty2

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

inside the AndroidManifest.xml file

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

    <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=".Acitivty2"/>

    </application>

</manifest>

Review the document Declare the activity in the manifest

    
answered by 20.09.2018 / 22:59
source