skip to Main Content

I wanted to show ‘RealMainActivity.kt’ to first main page, so I wrote below.

  <activity android:name=".RealMainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

but there is still Error running ‘app’: The activity must be exported or contain an intent-filter.
Do I need more other route settings here?

Below is all the code about ‘AndroidManifest.xml’

<?xml version="1.0" encoding="utf-8"?>

<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.Swu_guru">

    <activity android:name=".WriteBorrow"/>
    <activity android:name=".BorrowList"/>
    <activity android:name=".BorrowInfo"/>
    <activity android:name=".RegisterActivity"/>
    <activity android:name=".RealMainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

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

</application>

2

Answers


  1. You need to include android: exported and set it to either true or false in your activity where you are using an intent filter. In your case it’s .RealMainActivity.

    <activity android:name=".RealMainActivity" android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
    
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    <activity android:name=".MainActivity"/>
    
    Login or Signup to reply.
  2. You have to place the exported=false in your launcher activity manifest tag if your app is targeting Android 12 (API 31). So you can add that attribute in your manifest or simply downgrade the targeting version to API 30 (Android 11).

    You can learn more about it here : Android 12 behavior changes

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search