560

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Saad Farooq
  • 13,172
  • 10
  • 68
  • 94

75 Answers75

1025

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sky Kelsey
  • 19,192
  • 5
  • 36
  • 77
  • 2
    You may also try to file a bug here: http://youtrack.jetbrains.com/issues/IDEA I find them to be very good at following up with bugs I file. – Sky Kelsey Apr 05 '13 at 03:25
  • I think this was it... I'll keep investigating... I didn't have time to open the directory again as a new project in each of the platforms. – Saad Farooq Apr 05 '13 at 23:50
  • I'm having the same problem. In my manifest file, I also get a "Cannot resolve symbol 'MainActivity'" error. I imported the project from Eclipse. – Roberto May 17 '13 at 04:54
  • Check configuration of your Android module. E.g. in case of Android project import from Cordova, it is necessary to mark src directory as Source in Modules setting. Check following [screenshots](http://georgik.sinusgear.com/2014/01/06/intellij-idea-cordova-default-activity-not-found-solution/) – georgik Jan 06 '14 at 20:37
  • 41
    This worked for me in Android Studio, but after restarting I also had to do Tools -> Android -> Sync Project with Gradle Files. – vaughandroid Aug 13 '14 at 08:32
  • @SkyKelsey The problem of Invalidating cache is that you will loose the history data. – agusgambina Jan 24 '15 at 14:09
  • But you will be able to build your project. You win some, you lose some. – Sky Kelsey Jan 28 '15 at 05:03
  • I make the mistake of putting upper case ANDROID.INTENT.ACTION.MAIN and ANDROID.INTENT.CATEGORY.LAUNCHER in my manifest file. Funny, cause I used auto-complete. Not sure why it inserted it as upper case. – freakvent Jul 15 '15 at 03:25
  • Still having to do this with upgrade to Android Studio 1.4 – Mike Fosker Oct 13 '15 at 14:36
  • Still happening some times. The solution proposed by Sky Kelsey works always. – 1lb3r Oct 29 '15 at 07:41
  • 4
    Check out this https://github.com/googlesamples/android-CommitContentSampleIME/issues/2#issuecomment-428936292 – Ninja Oct 11 '18 at 12:32
  • 3
    Didn't work for me. I'm having to settle for launching the app manually. This sucks. – David Heisnam Oct 30 '18 at 10:55
  • Is there a permanent solution cause I need to Invalidate caches and Restart studio everytime I launch it? – Ishaan Dec 14 '18 at 06:08
  • @vaughandroid , that syncing was the only what I did and the error gone . – CodeToLife Dec 29 '18 at 10:19
  • 4
    sometimes this occurs, but the problem is somewhere else, for example my problem was in too low minSdkVersion – Kochchy Apr 01 '20 at 14:02
348

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mattgmg1990
  • 5,576
  • 4
  • 21
  • 26
  • ant builds it fine and so does IntelliJ 12.0.4 – Saad Farooq Apr 05 '13 at 03: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. – The_Martian Aug 15 '15 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 Oct 17 '15 at 08:14
  • 29
    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 Mar 10 '16 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. – Chinese Cat Oct 26 '18 at 00:58
  • If neither of this 2 solution worked then go into Settings-> Apps->See All Apps. See if your app is not installed for all users. If your app is not installed for all users simply use adb command to uninstall this app. After that reinstall your app, it should work now. – Hitesh Sahu May 22 '19 at 13:40
  • @mattgmg1990 i have edited your answer inorder to include additional details. – divine Feb 27 '21 at 17:00
  • This should be marked as the correct answer. And it makes sense. – Shehan DMG Dec 30 '22 at 09:37
  • Ten years on, you helped me hack my very beginner work into shape. Someone should write a "for impatient developers" guide to android development. Much appreciated – Michael McPherson Jun 03 '23 at 20:51
100

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
David Hackro
  • 3,652
  • 6
  • 41
  • 61
  • 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 Sep 22 '16 at 11:40
  • This is the only answer that worked for apps without activity. Thank you. – sephiron Oct 05 '16 at 00: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 Mar 14 '19 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 Jun 24 '19 at 09:47
  • This answer was easy to follow. Also the comment from @Udi Reshef thanks – Bishwas Mishra Nov 28 '19 at 06:43
  • 4
    I selected Launch: "Nothing" option and works for me :) – Andy Jun 29 '20 at 18:48
  • I had selected wrong module in launch configuration which did not have launcher activity, correcting this solved my problem, thanks! – NeeK Jul 21 '21 at 07:46
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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 3
    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 Sep 21 '20 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 Nov 27 '20 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.

Rahul Gaur
  • 1,661
  • 1
  • 13
  • 29
Yuriy Vasylenko
  • 3,031
  • 25
  • 25
  • 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 Oct 17 '15 at 08:13
  • Good Point : "This should be inserted between: ". This was my issue. Thanks a lot. – Dennis Mathew Apr 03 '17 at 08: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. – Kenny Dabiri Oct 04 '17 at 01: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? – pdoherty926 Jun 18 '18 at 02: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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Micer
  • 8,731
  • 3
  • 79
  • 73
  • 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 – Jesse Black May 22 '14 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 Sep 20 '14 at 05:26
  • 2
    Works like a charm, Removed the current root, and added the parent folder of src and gen again – Udi Oshi Nov 25 '14 at 20:48
  • 2
    a quick way to access the module settings is to click in the project navigator and press F4 – whyoz Feb 04 '15 at 23:23
  • 4
    this is deprecated since there is no **Sources** tab at **Open Module Settings** anymore. – Buddy Aug 07 '15 at 21:30
  • Was trying to build one of Google's own samples and this was the thing that fixed it for me. Specifically in my version (2.1.1) this was in File->Project Structure->Modules. – SilentDirge May 18 '16 at 19:53
38

In Android Studio 4.0, please change Launch to Nothing:

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

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tao Nhu
  • 1,980
  • 1
  • 15
  • 6
  • 6
    Updating Android Studio to 4.x gave me this issue, tried the common stuff. Only this works! – Ferdau Jun 12 '20 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. – David Rauca Jul 21 '20 at 08:50
24

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

TouchBoarder
  • 6,422
  • 2
  • 52
  • 60
  • 4
    This is the solution when the project is a service, or has no default activity for some other reason. – Aharon Manne Sep 27 '16 at 08:20
  • 3
    In Android Studio 2.2.3; Run/Debug Configuration -> Android App -> myApp -> General -> Launch Options -> Launch : Nothing – liteflier Jan 05 '17 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>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yuliskov
  • 1,379
  • 15
  • 16
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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Salman
  • 781
  • 6
  • 9
  • 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 Jan 10 '19 at 02:34
  • 1
    This worked for me. What I believe caused this was moving my main activity to a different directory, downstream from the root. – Shane Sepac Apr 16 '19 at 01:47
19

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">
Rinkesh
  • 3,150
  • 28
  • 32
Nehemiah Narzary
  • 336
  • 4
  • 11
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.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user924
  • 8,146
  • 7
  • 57
  • 139
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
12

Exit Android Studio.

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

Remove the /caches folder and the /tmp folder.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abhishek Garg
  • 3,092
  • 26
  • 30
  • 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 Aug 17 '20 at 06: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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
bio007
  • 893
  • 11
  • 20
  • Wish I'd seen this before blowing four hours on finding the same thing. Must be a recent change. – Mike M Sep 02 '20 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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pankaj Sejwal
  • 1,605
  • 1
  • 18
  • 27
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.
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sifr_dot_in
  • 3,153
  • 2
  • 33
  • 42
  • That's very understandable, and much more valuable answer than the accepted one. – Evgeniy Mishustin Aug 26 '20 at 08: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 Sep 02 '20 at 11:48
  • the manifest one fixed my problem it told to increase min sdk version so i fixed it –  Dec 06 '20 at 09: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>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mehmoodnisar125
  • 1,469
  • 18
  • 14
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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
John
  • 6,433
  • 7
  • 47
  • 82
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • I figured out that just `Syncing Project With Gradle Files` worked fine as wine. By the way my error occurred from nowhere. – homerun Jul 29 '19 at 08: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.

black
  • 781
  • 1
  • 7
  • 22
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.

Muz
  • 5,866
  • 3
  • 47
  • 65
  • in my case the renaming of FilterClasses led to the tags :) – Emanuel Jan 11 '17 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. – Kenny Dabiri Oct 04 '17 at 01:35
  • Isn't there some XML schema to detect such problems automatically (for example, to include in a test suite or build system)? – Peter Mortensen May 07 '22 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!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ahmed Adel Ismail
  • 2,168
  • 16
  • 23
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Artyom
  • 1,099
  • 15
  • 18
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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
homerun
  • 19,837
  • 15
  • 45
  • 70
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
PrzemekTom
  • 1,328
  • 1
  • 13
  • 34
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">
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
KufuT
  • 77
  • 6
2

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lokesh Tiwari
  • 10,496
  • 3
  • 36
  • 45
2

I just faced this error in Android Studio 2.1.2.

I solved by adding the MAIN/LAUNCHER intent-filter to the default activity in flavour manifest, though filter already was in the default activity in the default manifest.

It even was in the merged manifest, but Android Studio couldn’t find it until I duplicated the filter in both manifests.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mjollneer
  • 1,005
  • 2
  • 19
  • 36
2

My experience:

Make sure that all your Java file has been identified. If IntelliJ IDEA does not identify your Java file, it is not able to understand what "Activity" means.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jianwei-x
  • 21
  • 1
2

Well, I got this error too,

Error: Default Activity Not Found

Well, in my case it was for wear module...I don't need an Activity there so I simply do:

  1. go to edit configuration → WearLaunch OptionsLaunchNothing.
  2. Apply changes. Click OK.
  3. Remove the existing code for the default activity from your manifest file.

Note: Don't forget to Clean Project and Sync Gradle Files.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
PN10
  • 1,888
  • 3
  • 23
  • 34
2

In the Android Manifest.xml, set the starting activity like the following:

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

    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Linu S
  • 79
  • 10
2

I was facing a similar issue recently. The issue was with the activitymanifest XML file.

Please check if taglines are closed properly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Can you [add](https://stackoverflow.com/posts/45908285/edit) some of XML content in question? (But ***without*** "Edit:", "Update:", or similar - the answer should appear as if it was written today). – Peter Mortensen May 07 '22 at 22:58
2

Edit file androidmanifest.xml

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

    <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=".MainActivityName">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tasdemir
  • 67
  • 3
2

Nothing in the previous answers helped me and Android Studio made this problem with all my apps that were running before already - so I knew - it does not has to do with my code.

Now I solved it:

You need to reset Android Studio: Just go to C:\Users\yourusername\androidStudio3.2 (or similar) and delete this directory.

This guy shows you exactly how to do it in his video in an older version:

How can we reset Android Studio to its default settings?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
pipafria
  • 102
  • 1
  • 2
  • 9
  • An answer should not depend on an external resource (that may break). Is deleting the directory sufficient or must something else be done for this work? – Peter Mortensen May 08 '22 at 15:08
2

Sometimes there is this error because of Android Studio misbehavior and because of the internal cache and project building system. Even we have set everything perfect for the default activity.

For such an issue, I found a solution and it is working for me.

Step 1. Android Studio → menu FileInvalid Cache and closed Android Studio.

Step 2. Go to path C:\Users\USER.AndroidStudio3.2\system

Step 3. Change the name with extension .back of the below folder

  Example: compiler should be *compiler.back*
  • compiler
  • compiler-server
  • conversion
  • external-build_system
  • framework
  • gradle
  • resource_folder_cache

Step 4: Start Android Studio and open your project.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Abhay Bhusari
  • 139
  • 1
  • 1
  • 2
    This was the only answer that worked for me, but in addition to the process described here, you must remove the contents of the "system/caches" folder otherwise it only works the first time after you have done the process and restart Android Studio, then it returned to happen the same, Default Activity Not Found. – Gerrard Feb 11 '19 at 15:49
  • The only option that worked for me. It happened after a hard computer reset, which probably corrupted some files as you said. The other option was to re-install android studio but luckily clearing the folders you specified is enough. – usernotnull Mar 15 '19 at 05:08
  • @Gerrard how strange. I tried the method above and everything else on the net and it did not work. I even reinstalled Android Studio and still nothing. Then I found your message and deleted system/caches and it worked. – Dinu Nicolae Aug 14 '20 at 12:19
2

I had this problem for two days. I tried every possible solution, but nothing worked. Finally, I found a solution.

Here is what you need to do:

  • Close Android Studio

  • Go to C:\Users\UserName.android and rename the build-cache folder to build-cache.bak

  • Go to C:\Users\UserName.AndroidStudio3.3\system and rename these folders

    • caches to caches.bak

    • compile-server to compile-server.bak

    • convert bat

    • conversion to conversion.bak

    • external_build_system to external_build_system.bak

    • frameworks to frameworks.bak

    • gradle to gradle.bak

    • resource_folder_cache to resource_folder_cache.bak

  • Open the Android Studio and open your project again.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rashid Kalhoro
  • 340
  • 4
  • 14
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

Go to ManifestMerged Manifest Tab (bottom of the screen).

In the right panel, if you have any error, resolve it!

This was the solution for me (an error with tool:replace not needed).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pauland
  • 1,974
  • 16
  • 25
2

How I solved this issue: I had no issue related to intent launcher declaration, and I even tried to manually declare the activity, but it still didn't work

I also cleared the cache and temporary folder, but nothing worked.

As I had several activities, it seems that one of the activities which I pulled from the repository had duplicate declarations:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

I started with a demo app and modified it. I change the java path inside source from com -> example -> foo to my own and edited the manifest; however, Android Studio (0.8.7) got very confused.

I tried everything listed above and none of it worked for me. Maybe it even made things worse?

My final solution was to edit <projectname>.iml in the .idea subdirectory by opening it up in Android Studio (aka text editor).

Before:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>

I (re)added the src directory (2nd line). After:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>

After saving it, Android Studio reloaded and started functioning as expected.

TrophyGeek
  • 5,902
  • 2
  • 36
  • 33
1

After updating Android Studio from 1.2.x to 1.3 I got the same problem and I tried all suggestions but nothing worked. Then I did this:

Go to Run/Debug Configurations. Select the configuration that gives the error and delete it. Create a new one with the same name and settings. After that, reconnect the USB cable and run the application.

This solved the problem for me.

1

Invalidate Caches / Restart


Just Restart


After that, your app must be run!

Orlando Herrera
  • 3,481
  • 1
  • 34
  • 44
1

You might be missing <intent_filter> attributes. Make sure to include this activity inside the manifest file.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Suman Astani
  • 1,181
  • 11
  • 16
  • 1
    Welcome to stackoverflow!! Try to avoid comment in answer unless you have specific answer. Please use comment box below and Once you have sufficient reputation you will be able to comment on any post. :) – Rucha Bhatt Joshi Jun 26 '17 at 10:39
1

I've encountered the same issue. For some reason, Android Studio replaced all the android:name attributes in most of XML files, including the manifest, to android:subject which isn't recognized by Android Studio.

Enter image description here

As you can see in the picture above, the IDE doesn't recognize the android:subject attribute. As a result, it won't be able to read the lines which specify the MainActivty.

The solution is simply to change every android:subject to android:name and then Rebuild the project from the Build menu* → Rebuild Project. You might encounter the same issue when rebuilding the project, so do the same as above.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Saif Hakeem
  • 875
  • 8
  • 9
1

I have been having this problem in Android Studio 3.0.1, and it was caused by manifest merge failure. For some reason I had not been given any error message in the message output. I had to check the merged manifest (app → manifests → *AndroidManifest.xml, and then the 'Merged manifest' tab).

There at the bottom there was an error indicating that the newest library, that was added in the build.gradle file, had a dependency on some other library whose minSdk was higher than my app minSdk. The solution was in this message and it was to add

<uses-sdk tools:overrideLibrary="timber.log"/>

to AndroidManifest.xml. Actually this library (piwik 1.0.2) had already this overrideLibrary in its manifest.

The strange thing was that other team members didn’t experience this problem.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
marcinj
  • 48,511
  • 9
  • 79
  • 100
1

Go to build.gradle (project: xyz)

buildscript {
    repositories {
        jcenter() 
        google()
    }
allprojects {
    repositories {
        jcenter()
        google()
    }

// Just place 'google()' to the top of 'jcenter()'

buildscript {
    repositories {
        google()
        jcenter()
    }
allprojects {
    repositories {
        google()
        jcenter()
    // enter code here
    }
}

It works perfectly for me.

itsmysterybox
  • 2,748
  • 3
  • 21
  • 26
1

Just clean and rebuild. The problem will be gone.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tushar Monirul
  • 4,944
  • 9
  • 39
  • 49
1

I tried the option Invalidate cache and restart, no luck. Then I verified the manifest. It was having the main activity intent properly set.

I was having the 'Offline work' checked under Global Gradle Settings in menu FileSettingsBuild, Execution, DeploymentGradle.

I unchecked it, modified the build.gradle file (Project) to use a different Gradle version (com.android.tools.build:gradle:3.3.1) and saved it. That triggered a Gradle sync.

After synchronising, this error was gone. I was able to debug again.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
smk
  • 301
  • 6
  • 13
1

For me, this problem occurred because of some other reason. So even though it has more than 30 answers, I still feel my solution might help someone.

My styles.xml was looking something like this:

<style name="AppTheme" parent="...">
    ....
</style>

<style name="AppTheme.NoActionBar" parent="...">
    ....
</style>

And my AndroidManifest.xml was something like this:

<application
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    ....
</application>

And for some reason, I decided to have my theme without ActionBar, so I went ahead and deleted it from my styles.xml. So here is the updated one:

<style name="AppTheme.NoActionBar" parent="...">
    ....
</style>

In addition to this, I had to update the theme in my manifest file, but I forgot that. So when I run the app, I got the error saying:

Error: Default Activity Not Found

After a long struggle, I found the problem and modified my manifest fle accordingly:

<application
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar">
    ....
</application>

Conclusion:

If you have a wrong AndroidManifest.xml which may lead into manifest merge failed, then AS can give this error.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Chandra Sekhar
  • 18,914
  • 16
  • 84
  • 125
1

You can get Android Studio to not complain by going to the "Edit Configurations" menu (tap "Shift" three times, and type "Edit Configurations"). Then change Launch OptionsLaunch to "Nothing".

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
1

Use menu FileInvalidate Caches / Restart...

Then reboot the machine (PC, laptop, etc.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
1

I got the same/similar error in a different scenario, Error: Default Activity Not Found, and was not able to run the project.

I found out that my project had minSdkVersion=16. However, one of the packages required minSdkVersion >= 21. I updated the dependencies and build again. Then I was able to run the project again.

I use Android Studio 4.0.1

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Puni
  • 1,214
  • 2
  • 18
  • 34
1

I was facing the same issue. In my case, I had declared an activity more than one time. After removing the duplicate activity, the error got resolved.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Black4Guy
  • 641
  • 11
  • 28
1

This problem is resolved with Android Studio 4.1

Benoit Canonne
  • 445
  • 6
  • 6
0

Well, I don't understand Android Studio sometimes...

I encountered the same problem and tried the what the answers here told, but to no avail.

And then I changed one thing: the action in my intent-filter was having the action name all in caps. I changed it to small and left only the word MAIN in caps, and it solved the problem! How absurd!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

I got the error:

Error: Default Activity Not Found after I copy pasted a code from an online course.

The mistake was in the first line in the MainActivity.java file.

Instead of package com.example.myname.justjava, the first line was package com.example.android.justjava.

From the code provided for learning, rectifying it got rid of the error.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Meenohara
  • 314
  • 4
  • 9
0

It was ugly, but it worked for me:

I had this error message, and my problem was in a module. I just deleted the application tag completely from my module's manifest and it worked.

(Delete ic_launcher from the module library as well.)

It was:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mymodule"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name="com.example.mymodule.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

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

</manifest>

Now:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mymodule"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="23"/>

</manifest>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
NBApps
  • 511
  • 5
  • 12
0

Check all the lines in your manifest.

In my case, I had this error:

android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"

And there wasn't anything in the LogCat.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Francesco Taioli
  • 2,687
  • 1
  • 19
  • 34
0

I got this error for trying to run an app that didn't have an activity (it was an androidTest project). So I just right clicked on the test project, and selected Run or Debug from the context menu.

live-love
  • 48,840
  • 22
  • 240
  • 204
0

Sometimes uninstalling the app for all users helps.

Go to the Application list in settings. Go to your app or scroll till the end of the list, and then uninstall it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
hemant patel
  • 114
  • 4
0

Check if an activity tag is present inside the application tag in the AndroidManifest.xml file.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
HimalayanCoder
  • 9,630
  • 6
  • 59
  • 60
0
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Just add this in your manifest file within <application> tags. Just replace MainActivity with your default activity and android.intent.action.youractivity will work.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ash
  • 1
0

If you already have the <intent-filter> tag, just be sure that you are closing all tags correctly.

My error was that I closed the <activity> tag just with a </> instead of </activity>.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alberto Alegria
  • 1,023
  • 10
  • 26
0

TL;DR:

Make sure that you do not only check the action and category name, but the path as well. Especially if you did a refactor.

The solution for me was to closely check the AndroidManifest file. I did a refactor, and it not only updated the intent-filters, but it also updated the path of the intent filter name:

<!-- Type and value were added to the 
     path here when I did the refactor -->
<action android:name="android.intent.type.MAIN"/>
<category android:name="android.intent.value.LAUNCHER"/>

It should be:

<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156
0

If the options in the previous answer do not work, try deleting the .gradle folder.

I am using Android Studio 3.3.1. All my projects were fine, when they all suddenly stopped working saying that there was no activity. Even brand new projects were showing the same error.

After hours invalidating cache, trying to fix the Manifest file. I've noticed that it had some relationship with Android X libraries, like (androidx.core:core-ktx). In some projects, just updating the libraries fix the problem, but what actually worked was deleting the .gradle folder.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
avelozo
  • 106
  • 1
  • 3
0

This solution should work for you:

  1. Go to Edit Configuration.

  2. Select Activity select nothing and apply.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shivegeeky
  • 183
  • 1
  • 7
0

None of the answers worked for me. The error message said:

Unable to read Manifest from ../path/to/the/apk

No default activity found

The error told me that somehow Android Studio is reading a previously-built APK file. Hence, I did ./gradlew clean to get rid of out folder which fixed the problem for me.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Robin Chander
  • 7,225
  • 3
  • 28
  • 42
0

It happened to me after upgrading to Android Studio 4.0.

I tried to invalidate caches, to delete and create again the Android App configuration, to select a specific Launch activity, but I always got the error stating that the activity wasn't defined in the AndroidManifest.xml file, but of course it was.

What worked for me is going to the Run/Debug configuration (where you define the Launch Options), removing the "Gradle-aware Make" on Before launch at the bottom of the dialog. I successfully ran the app and then I added the "Gradle-aware Make" again and everything was working.

It does not make sense, I know. But that was what I did.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Paolo Godino
  • 21
  • 1
  • 4
0

In my case this happened, because there's was a manifest merger error and I was trying to run the app.

Look at the specific error by running BuildMake Project.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rubin Yoo
  • 2,674
  • 2
  • 24
  • 32
0

Go to the manifest file. Then go merge the manifest file, see an error, and solve the manifest issue.

Clean the project and run.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

The issue in my case was:

In my app module manifest, I had to replace another dependency module manifest tag.

I added the below code under the application tag and it worked for me:

tools:replace="android:allowBackup, android:usesCleartextTraffic"

For you it might be due to some other properties. You must override them as well.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vikash Bijarniya
  • 404
  • 4
  • 10
0

Adding package="your.package.path" solved this. I am not sure why though. I had to create a new sample flutter project and compare config files with mine to find this out.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.abc.app">...</manifest>
-4

While configuring a new project

The company name should end as .app. For example, it should be android.example.com.app and it should not be android.example.com.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shivanand T
  • 1,093
  • 1
  • 10
  • 18