546
votes

I upgraded IntelliJ Idea from 12.0.4 to 12.10.

Now all the modules in my Android project give the error:

Error: Default Activity Not Found

I reverted back to 12.0.4 and it everything works again.

Any ideas? I think it might be an issue with a missing plugin. Since the plugin is not installed, it is not able to find the default activity. Another thing could have been a local config, but I doubt it. I deleted the configuration folder to verify and that didn't change anything.

30
have you looked at the manifest? maybe switching versions cleared it or something? developer.android.com/guide/components/fundamentals.htmlMaxOvrdrv
No... but I got it to work with 12.0.4 but re-importing the project from scratch.Saad Farooq
Manifest's the key, probably a name error or omission, or a namespace problemslezica
A Manifest problem in all seven modules of the project that 12.0.4 runs correctly but 12.10 doesn't ??Saad Farooq
No, but a change in a namespace or something project layout, for example, might have gone out of sync with the manifestslezica

30 Answers

1010
votes

If you see that error occur after upgrading versions of IntelliJ IDEA or Android Studio, or after Generating a new APK, you may need to refresh the IDE's cache.

File -> Invalidate Caches / Restart...
340
votes

I can't comment on why the upgrade of IntelliJ might cause this problem because I don't use it.

However, that error: "Default Activity Not Found" seems to be telling you that you don't have an activity declared in AndroidManifest.xml that is marked as the main activity, to be launched when the application starts.

You should have at least one activity that looks something like this:

<activity
        android:name="com.your.package.name.YourActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

If you don't have at least one activity with an intent filter like that, you would most likely see the error message you have included here.

You should add that intent filter to the Activity that you wish to open when you start the application, and that should fix your problem.

Edit:

Additional details (AndroidStudio4.1.2) if the project is created as EmptyApplication then the developer must manually create below 3 files to avoid Default Activity Not Found error

AndroidManifest.xml enter image description here MainActivity.java enter image description here activity_main.xml enter image description here

99
votes

You app have launch activity default?

possibly this could be your mistake

enter image description here

Step 1: Select Edit Configurations

enter image description here

Step 2: watch this warning: Default Activity not found enter image description here

Step 3: select a default activity enter image description here

enter image description here

Step 3: Save your changes and finish

enter image description here

Good Luck

enter image description here

79
votes

If you are working on a widget app this solution should work for you:

  1. Go to Edit Configuration
  2. Set Launch Option to nothing
68
votes

The correct way to do this is to add the following to the Manifest file:

<activity
    android:name="FULL_NAME_OF_YOUR_ACTIVITY"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

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

This should be inserted between:

<application> </application>

No need in invalidating caches.

44
votes

Try to right click on the project and choose Open Module Settings. Then go to the Sources tab in your module, find the src folder, right click on it and mark it as Sources (blue color).

EDIT: There is no sources tab in later versions of Android Studio, but you can edit the build.gradle file instead: https://stackoverflow.com/a/22028681/1101730

37
votes

In Android Studio 4.0 please change Launch to Nothing:

Run/Debug Configuration -> Android App -> app -> General -> Launch Options -> Launch : Nothing

enter image description here

25
votes

In Android Studio under Run/Debug Configuration -> Android Application -> General -> Activity -> select the option "Do not launch Activity".

23
votes

Nothing above helped me. After some time I found that IDEA changed action names to uppercase. Like:

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

After reverting to normal, IDEA recognizes default activity:

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

Firstly make sure that you have included default activity in manifest.

Example:

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

If you have tried everything and nothing seems to works then

  • Delete the cache from your %Home%\.gradle\caches and sync project again.

Or check this answer

https://stackoverflow.com/a/53476487/5507705

18
votes

100% working

You must be seeing this

enter image description here

First open your manifest and check if this present,

  <activity
      android:name="com.your.package.name.YourActivity"
      android:label="@string/app_name">
       <intent-filter>
           <action android:name="android.intent.action.MAIN" />
           <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
   </activity>

If not present add it

If the above is present but still you see default activity not found.

Follow these steps:

1. Click edit configuration

enter image description here

2. On clicking edit configuration you'll see that launch option is set on DEFAULT ACTIVITY

enter image description here

  1. Change it to nothing.

enter image description here

Problem solved!

Happy Coding.

13
votes

In my case File -> Invalidate Caches / Restart... didn't help

Everything was ok with my project and of course I had next intent filter for my activity

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

What really helped me is deleting Android/Gradle cache folders (they can grow up to 10-30 GB)

Go to C:\Users\YOUR_USER_WINDOWS_NAMEand delete next folders

  • .android
  • .AndroidStudio3.2
  • .gradle

(you may save some Android configs from .AndroidStudio3.2 before deleting it if you want it)

You can create bat file CLEAR_CACHE.cmd like this to delete folders without Recycle Bin

rmdir /S /Q .android
rmdir /S /Q .AndroidStudio3.2
rmdir /S /Q .gradle

it would work much faster and you don't have to delete it also from Recycle Bin

p.s. put CLEAR_CACHE.cmd into C:\Users\YOUR_USER_WINDOWS_NAME

it's also a good idea to delete Android Studio folder and download it again

12
votes

This method works for me Click on the app icon and then choose edit configurations. In the edit-configuration choose specified activity instead of the default activity. Then give the path of the activity below.

Click on app and edit configuration

Choose the specified activity and the directory

In the end sync with the gradle files.

12
votes

Exit Android Studio.

Go to path C:\Users\YOUR_WINDOW_USER_NAME\.AndroidStudio3.3\system

Remove /caches folder and /tmp folder

12
votes

As this question is a "landing page" for plethora of issues with manifest, resulting in no Default Activity found, here is another thing to check if you are having this problem.

Open your Manifest and switch to Merged Manifest tab.

Sometimes the issue is related to merging all the manifests in the project to one, which can result to error and therefore "Default Activity not found". The problem is this error is not shown anywhere except this Merged Manifest tab as far as I know.

Es: in a project minSdkVersion 10, downgrade the version of implementation in build.gradle file: from 25.4.0 to 25.3.1 solve this problem.

dependencies {
implementation 'com.android.support:appcompat-v7:25.3.1'   
implementation 'com.android.support:design:25.3.1'         
implementation 'com.android.support:mediarouter-v7:25.3.1' 

Merged Manifest

11
votes

This occurred to me after my PC restarted unexpectedly.
Strangely, I had made no changes and still got this error.
None of the above helped me. What solved my problem, is this.
Step 1: enter image description here


Step 2: enter image description here


Step 3: enter image description here

If this doesn't solve the problem give other tries.

Try 1:

File -> Invalidate Caches / Restart...

Try 2:
check whether these following two lines

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

are in your launcher activity declaration in manifest.xml

<activity
        android:name="com.your.package.name.YourActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

Try 3:

  1. Click as shown: enter image description here

  2. Run / Debug Configurations opens. enter image description here





if this also doesn't help.
Try 4:

  1. File->Export to ZIP.
    and
  2. Import it as new project.

Best luck.

10
votes

I changed my Intent-filter to

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

Just add DEFAULT option as well. I was using the Process Phoenix library and it prompted me to define a default intent. This addition solved my problem.

8
votes

I got this error.

And found that in manifest file in launcher activity I did not put action and category in intent filter.

Wrong One:

<activity
android:name=".VideoAdStarter"
android:label="@string/app_name">

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

</activity>

Right One:

<activity
android:name=".VideoAdStarter"
android:label="@string/app_name">

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

</activity>
6
votes

@TouchBoarder almost had it. Although selecting "Do not launch Activity" results in nothing launching.

In Android Studio under Run/Debug Configuration -> Android Application -> General -> Activity -> select the option "Launch:"

Choose your Activity. This doesn't exactly fix the intended behaviour but rather overrides it correctly.

Edit run/debug configurations and specify launch activity

4
votes

In case your application doesn't have an Activity (only a service for example), change the run/debug configuration 'Launch' option to Nothing.

4
votes

I found this in my code:

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

If you look very carefully, it should be <activity android:name=".MainActivity"> instead.

Apparently, I refactored an "activity" somewhere, and it changed names in the AndroidManifest as well.

4
votes

I found this blog that really fixed this issue in my case. It turns out you have to add some sort of intent:

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

It was definitely straightforward. Reference:

https://www.aboutonline.info/2018/08/error-running-app-default-activity-not-found-on-android-with-kotlin.html

4
votes

All answers above didn't help me. Try to remove this

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

in your AndroidManifest. Then:

File > Sync Project with Gradle Files
4
votes

In my case I refactored a member variable that was named "activity", I renamed it to "context"... I found out that the refactor was made to the activity tags in manifest, and I found them context tags instead... this is really stupid from Android Studio!

3
votes
  1. Build -> Rebuild Project
  2. File -> Invalidate Caches.. -> Invalidate and restart

It works for me. Rebuild project to make sure that no errors in project. Then we can invalidate cache.

3
votes

I have the same problem in Android Studio 3.3 Canary 3. Project from Android Studio 3.0 stabile version works firstly correctly, than after some cleans/rebuilds it starts showing No Default Activity error. I tried to reinstall this alpha version of Android Studio: error again. But then started it in old stabile Android, and using apk install, and this apk works correctly.

Moreover my project was created with Instant App (base, feature, instant, app subdirectories). I think this Android Studio has some problems with Manifest.xml files separated into this multiple directories.

So I have changed in settings to this: enter image description here

3
votes

Sync Project With Gradle Files works sometimes, To fix this Overall issue you should

  1. Exit Android Studio
  2. Go to USER -> AndroidStudio -> system -> caches
  3. Delete that folder
  4. Start Android Studio.

It will re-index your files and that should work

Thanks to kirtan403 from a similar question.

3
votes

Since Android Studio 3.5 or 3.6 I started getting the Default Activity not found and I became tired of Invalidating Caches & Restart, rebuilding project etc.

It turned out, the way I handle multi-modules and manifests was erroneous. I had the default Activity's Manifest in library module only, but it should've been in both app modules.

Assuming librarymodule appmodule1 appmodule2

  1. Remove HomeActivity from librarymodule Manifest whatsoever.
  2. Add:
class AppModuleActivity1 : HomeActivity() to appmodule1
class AppModuleActivity2 : HomeActivity() to appmodule2
  1. To appmodule1 Manifest inside application tag, I added:
        <activity
            android:name="com.app.name.AppModuleActivity1">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
  1. Same about appmodule2 but change 2 for 1 in naming.
2
votes

In my case, there was a misstype in AndroidManifest.xml as shown below. Removing "o" letter above application tag solved. Apparently, Android Studio doesn't detect type errors in AndroidMainfest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

o
<application android:name=".AppName"
             android:allowBackup="false"
             android:icon="@drawable/ic_launcher"
             android:label="@string/app_name"
             android:theme="@android:style/Theme.Light.NoTitleBar">
2
votes

Error: Default Activity Not Found

I solved this way
Run>>Edit Configuration >>Android Application >> Enter the path of your default activity class in "Launch" Edit Box.