566

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 configuration, but I doubt it. I deleted the configuration folder to verify and that didn't change anything.

9
  • 3
    have you looked at the manifest? maybe switching versions cleared it or something? developer.android.com/guide/components/fundamentals.html
    – MaxOvrdrv
    Commented Apr 5, 2013 at 2:55
  • No... but I got it to work with 12.0.4 but re-importing the project from scratch. Commented Apr 5, 2013 at 3:07
  • 2
    Manifest's the key, probably a name error or omission, or a namespace problem
    – salezica
    Commented Apr 5, 2013 at 3:09
  • A Manifest problem in all seven modules of the project that 12.0.4 runs correctly but 12.10 doesn't ?? Commented Apr 5, 2013 at 3:17
  • No, but a change in a namespace or something project layout, for example, might have gone out of sync with the manifest
    – salezica
    Commented Apr 5, 2013 at 3:46

75 Answers 75

1026

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

Menu FileInvalidate Caches and restart...

15
  • 2
    You may also try to file a bug here: youtrack.jetbrains.com/issues/IDEA I find them to be very good at following up with bugs I file.
    – Sky Kelsey
    Commented Apr 5, 2013 at 3:25
  • 41
    This worked for me in Android Studio, but after restarting I also had to do Tools -> Android -> Sync Project with Gradle Files. Commented Aug 13, 2014 at 8:32
  • 4
    Check out this github.com/googlesamples/android-CommitContentSampleIME/issues/…
    – Ninja
    Commented Oct 11, 2018 at 12:32
  • 3
    Didn't work for me. I'm having to settle for launching the app manually. This sucks. Commented Oct 30, 2018 at 10:55
  • 4
    sometimes this occurs, but the problem is somewhere else, for example my problem was in too low minSdkVersion
    – Kochchy
    Commented Apr 1, 2020 at 14:02
365

I can't comment on why the upgrade of IntelliJ IDEA 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 file 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.

Additional details

(Android Studio 4.1.2) if the project is created as EmptyApplication then the developer must manually create below three files to avoid the Default Activity Not Found error:

File AndroidManifest.xml

Enter image description here

File MainActivity.java

Enter image description here

File activity_main.xml

Enter image description here

9
  • ant builds it fine and so does IntelliJ 12.0.4 Commented Apr 5, 2013 at 3:22
  • I started my app in Eclipse, yes I have a default activity. I imported my app to Android studio it was fine until one day I added notification manager and stuff, that is when I run into this error. I did File->Invalidate cach->Restart and that fixed it. But the error was not caused by the lack of default activity as you stated. Commented Aug 15, 2015 at 20:55
  • Worked for me too! BUT NOTE: please write "android.intent.xxx" in lowercase letters - my fault was that the Android Studio completion suggested uppercase letters (this took me one hour) :-(
    – Philipp P
    Commented Oct 17, 2015 at 8:14
  • 32
    For those who are relatively new to Android and you've just screwed up your Android Studio project, this is the answer you're looking for. The accepted answer is for when an upgrade has screwed things up for you.
    – Tom Kidd
    Commented Mar 10, 2016 at 17:10
  • 3
    I have set this and my project already run many times and it gets wrong suddenly. I don't know where is wrong. Perhaps, it's a potentially bug of AS. Commented Oct 26, 2018 at 0:58
102

If your app has a 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

7
  • Good answer! This what helps if there is no activity in the app. (only service). you need to change in "activity" to "do not launch activity"
    – Udi Reshef
    Commented Sep 22, 2016 at 11:40
  • This is the only answer that worked for apps without activity. Thank you.
    – sephiron
    Commented Oct 5, 2016 at 0:51
  • This worked for me! I actually had a Default Activity in the Manifest, but for some reason Android Studio didn't find that.
    – ocramot
    Commented Mar 14, 2019 at 18:11
  • 13
    I followed the aforementioned steps but now it says "The activity 'MainActivity' is not declared in AndroidManifest.xml" although MainActivity is there
    – Far
    Commented Jun 24, 2019 at 9:47
  • 4
    I selected Launch: "Nothing" option and works for me :)
    – Andy
    Commented Jun 29, 2020 at 18:48
79

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
2
  • 4
    This is just skip the problem, but it doesnt fix it. The app wont run at the end of build after set to nothing
    – Leo Paim
    Commented Sep 21, 2020 at 20:39
  • I did this. It didn't correct, but displayed an error that I could correct. After setting back to Default Activity, it worked. (My application isn't a widget)
    – Thomas
    Commented Nov 27, 2020 at 18:52
68

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.

4
  • Worked for me too! BUT NOTE: please write "android.intent.xxx" in lowercase letters - my fault was that the Android Studio completion suggested uppercase letters (this took me one hour) :-(
    – Philipp P
    Commented Oct 17, 2015 at 8:13
  • Good Point : "This should be inserted between: <application> </application>". This was my issue. Thanks a lot. Commented Apr 3, 2017 at 8:41
  • Be very careful when refactoring your codes. in my own case, I mistakenly refactored 'category' as 'phone' thus, android.intent.category was changed to android.intent.phone. Commented Oct 4, 2017 at 1:35
  • I used Android Studio's project creation wizard and still had to do this manually. Am I wrong for thinking that is a bug? Commented Jun 18, 2018 at 2:45
44

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

There is no sources tab in later versions of Android Studio, but you can edit the build.gradle file instead: How to add a linked source folder in Android Studio?

6
  • This helped me out, I realized intellij dropped a lot of source files from the src in the Sources tab. I moved my package out of the project and back in. That solved my problem Commented May 22, 2014 at 21:52
  • 3
    I did this same kind of thing, but I right-clicked the src folder and went to "Mark Directory As..." and then "Sources Root." - Android Studio 0.8.6
    – elliptic1
    Commented Sep 20, 2014 at 5:26
  • 2
    Works like a charm, Removed the current root, and added the parent folder of src and gen again
    – Udi Oshi
    Commented Nov 25, 2014 at 20:48
  • 2
    a quick way to access the module settings is to click in the project navigator and press F4
    – whyoz
    Commented Feb 4, 2015 at 23:23
  • 4
    this is deprecated since there is no Sources tab at Open Module Settings anymore.
    – Buddy
    Commented Aug 7, 2015 at 21:30
38

In Android Studio 4.0, please change Launch to Nothing:

Run/Debug ConfigurationAndroid AppappGeneralLaunch Options → set Launch to Nothing.

Enter image description here

2
  • 6
    Updating Android Studio to 4.x gave me this issue, tried the common stuff. Only this works!
    – Ferdau
    Commented Jun 12, 2020 at 12:09
  • This is not really a good solution to change to Nothing. It works, that is true, but the app will only be installed on the device and you have to run it manually. On my side I just had to check the Manifest file. I had 2 activities declared twice. Now, after removing the duplications, I can run the project without problems with "Default Activity" for launch options. Commented Jul 21, 2020 at 8:50
24

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

2
  • 4
    This is the solution when the project is a service, or has no default activity for some other reason. Commented Sep 27, 2016 at 8:20
  • 3
    In Android Studio 2.2.3; Run/Debug Configuration -> Android App -> myApp -> General -> Launch Options -> Launch : Nothing
    – liteflier
    Commented Jan 5, 2017 at 16:25
23

Nothing in the previous answers helped me. After some time I found that IntelliJ 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 the default activity:

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

Firstly make sure that you have the 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:

Android Studio shows wrong file contents

2
  • 1
    Android Studio 3.2.1: File -> Sync Project with Gradle Files ::: Had to do this after invalidating cache and restarting before the problem went away.
    – Kreebog
    Commented Jan 10, 2019 at 2:34
  • 1
    This worked for me. What I believe caused this was moving my main activity to a different directory, downstream from the root. Commented Apr 16, 2019 at 1:47
21

This solution is 100% working

You must be seeing this:

Enter image description here

First, open your manifest and check if this is 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 the launch option is set on DEFAULT ACTIVITY

    Enter image description here

  3. Change it to nothing.

    enter image description here

Problem solved!

Note

Please make on the root of the manifest file you should have the package name

        <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
        package="com.package.name">
0
13

In my case menu FileInvalidate Caches / Restart... didn't help.

Everything was OK with my project and of course I had the following 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 was deleting the Android/Gradle cache folders (they can grow up to 10-30 GB).

Go to C:\Users\YOUR_USER_WINDOWS_NAME and delete the following folders

  • .android
  • .AndroidStudio3.2
  • .gradle

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

12

This method works for me. Click on the app icon and then choose edit configurations.

In the edit-configuration, choose the 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, synchronise with the Gradle files.

12

Exit Android Studio.

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

Remove the /caches folder and the /tmp folder.

1
  • 1
    Oh my, it's only one solution which helps me when Android Studio broking its caches and think that some of my project files are broken. It's awful, but I'm really glad to find your solution on the second page)
    – Acuna
    Commented Aug 17, 2020 at 6:42
12

As this question is a "landing page" for plethora of issues with manifests, 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.

For example: 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

1
  • Wish I'd seen this before blowing four hours on finding the same thing. Must be a recent change.
    – Mike M
    Commented Sep 2, 2020 at 11:51
10

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

0
10

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, was 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:

Menu FileInvalidate Caches / Restart...

Try 2:

Check whether the following two lines,

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

are in your launcher activity declaration in file 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 doesn't help either:

Try 4:

  1. Menu FileExport to ZIP.

and

  1. Import it as a new project.
3
  • That's very understandable, and much more valuable answer than the accepted one. Commented Aug 26, 2020 at 8:22
  • 1
    I just ran into this exact same thing with the merged manifest - would be nice if Android Studio had highlighted this tab to show that there was an error. :-/
    – Mike M
    Commented Sep 2, 2020 at 11:48
  • the manifest one fixed my problem it told to increase min sdk version so i fixed it
    – user14162811
    Commented Dec 6, 2020 at 9:57
8

I got this error.

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

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

The 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

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

In Android Studio under Run/Debug ConfigurationAndroid ApplicationGeneralActivity → 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

5

All previous answers didn't help me.

Try to remove

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

in your AndroidManifest.

Then menu FileSync Project with Gradle Files.

1
  • I figured out that just Syncing Project With Gradle Files worked fine as wine. By the way my error occurred from nowhere.
    – homerun
    Commented Jul 29, 2019 at 8:53
4

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

4

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.

3
  • in my case the renaming of FilterClasses led to the <intent-filterList> tags :)
    – Emanuel
    Commented Jan 11, 2017 at 12:29
  • 2
    Be very careful when refactoring your codes. in my own case, I mistakenly refactored 'category' as 'phone' thus, android.intent.category was changed to android.intent.phone. Commented Oct 4, 2017 at 1:35
  • Isn't there some XML schema to detect such problems automatically (for example, to include in a test suite or build system)? Commented May 7, 2022 at 22:48
4

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 the manifest, and I found them to be context tags instead... this is really stupid from Android Studio side!

1
  • 2
    this is a bug from Android studio, you are right @tere bentikh Commented Feb 17, 2017 at 9:29
3
  1. Menu BuildRebuild Project
  2. Menu FileInvalidate Caches...Invalidate and restart

It works for me.

Rebuild the project to make sure that there aren't any errors in the project. Then we can invalidate the cache.

3

Error: Default Activity Not Found

I solved it this way:

RunEdit ConfigurationAndroid Application → *enter the path of your default activity class in the "Launch" Edit Box.

1
  • What about on VS code?
    – Alex Maina
    Commented Nov 14, 2021 at 7:03
3

I have the same problem in Android Studio 3.3 Canary 3.

The project from the Android Studio 3.0 stable version works firstly correctly, but then after some cleans/rebuilds, it starts showing the No Default Activity error.

I tried to reinstall this alpha version of Android Studio: error again. But then I started it in the old stabile Android, and using APK install, and this APK file works correctly.

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

So I have changed it in settings to this:

Enter image description here

3

Sync Project With Gradle Files works sometimes.

To fix this overall issue you should:

  1. Exit Android Studio
  2. Go to folder USERAndroidStudiosystemcaches
  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.

0
3

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
    
  3. 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>
    
  4. Same about appmodule2 but change 2 for 1 in naming.

2

This is still happening with Android Studio 4.0, so I have to delete the following folder to fix this problem:

C:\Users\my_user_name.AndroidStudio4.0\system\caches

2

In my case, there was a typo in AndroidManifest.xml as shown below. Removing the "o" letter above the application tag solved it.

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">
3
  • As it works in one version and not work on another, it could not be the same problem as yours.
    – Ravi Bhatt
    Commented Jun 13, 2014 at 10:13
  • 2
    Thats why i said "in my case"
    – KufuT
    Commented Apr 29, 2016 at 12:32
  • But isn't it syntactically correct XML (not a rhetorical question)? Is there an XML schema for it? Commented May 2, 2022 at 20:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.