[java] The activity must be exported or contain an intent-filter

when I tried to run my application its show the error below

Error running Dashboard: The activity must be exported or contain an intent-filter

How can I solve this error?

This question is related to java android android-activity

The answer is


Check your manifest,Open the file with .xml extension and then all your activities are listed your first activity should have this code enclosed in its tags

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

or there is another way u can choose from configuration which is drop down list on the left side of run button choose from App from it Hope it will help!!


it's because you are trying to launch your app from an activity that is not launcher activity. try run it from launcher activity or change your current activity category to launcher in android Manifest.


just add intent-filter Tag inside your activity

for example ::

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

Double check your manifest, your first activity should have tag

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

inside of activity tag.

If that doesn't work, look for target build, which located in the left of run button (green-colored play button), it should be targeting "app" folder, not a particular activity. if it doesn't targeting "app", just click it and choose "app" from drop down list.

Hope it helps!


First check a Launch Activity is set in your 'manifest.xml' file has:

<activity android:name=".{activityName}">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

If this is set correctly, next check your run/debug configuration is set to 'App',

enter image description here

If the 'App' configuration is missing - you will need to add it by first selecting 'Edit Confurations'

enter image description here

If you do not have a 'App' configuration you will need to create one, else select you 'App' configuration and skip the creating steps. Also if your configuration is corrupt you may need to delete it but first backup your project. To delete a corrupt configuration, select it by expanding the 'Android App' node and chose the '-' button.

enter image description here

To create a new configuration, select the '+' button and select 'Android App'

enter image description here

If you have just created the configuration you will be presented with the following default name value of 'Unnamed' and module will have the value '<no module>' then hit 'Apply' and 'OK'.

enter image description here

Set this the name to 'App' and select 'app' as the module.

enter image description here

Next select 'App' as the run configuration and Run.

enter image description here

Thats it!


I changed the Select Run/Debug Configuration from my MainActivity to App and it started working. Select App configuration snapshot:

enter image description here


If you're trying to launch a specific activity instead of running the launcher one. When you select that activity. the android studio might through this error, Either you need to make it launcher activity, just like answered by few others. or you need to add android:exported="true" inside your activity tag inside manifest. It allows any external tool to run your specific activity directly without making it a launcher activity


Just Select App from dropdown menu with Run(green play icon). it will run the whole the App not the specific Activity. if it doesn't help try to use in that activity in ManiFest.xml file. thankyou


In manifest.xml, select activity which u wanna start e set this informations:

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

Sometimes if you change the starting activity you have to click edit in the run dropdown play button and in app change the Launch Options Activity to the one you have set the LAUNCHER intent filter in the manifest.


Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-activity

Kotlin Android start new Activity The activity must be exported or contain an intent-filter How to define dimens.xml for every different screen size in android? Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which? Not an enclosing class error Android Studio java.lang.IllegalStateException: Fragment not attached to Activity Soft keyboard open and close listener in an activity in Android android.app.Application cannot be cast to android.app.Activity Android Shared preferences for creating one time activity (example) Android ListView with onClick items