android studio default activity not found

С такой бедой столкнулся, когда захотел запустить написанное приложение на виртуальном устройстве. Ошибка появляется из-за того, что у Вас не указана «рабочая область по умолчанию». Исправляется ошибка следующим образом, сначала открываем панель конфигурации.

Здесь ищем опции загрузчика (Launch Options), и вместо Default Activity:

Выбираем Specifed Activity, а также выбираем интересующий нас вариант.

I just upgraded to Android Studio 0.2.8 and I am getting an error that says «Default Activity not found» when I try to edit the run configurations.

When I launch Android Studio I get this error «Access is allowed from event dispatch thread only»

The activity I am using is a fragment activity.

So far I’ve tried rebuilding and invalidate caches/restart. Both were of no use.

Please let me know what I can do to fix the problem.

21 Answers 21

In Android Studio, 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 (thanks for comment Josh)

Have you added ACTION_MAIN intent filter to your main activity? If you don’t add this, then android won’t know which activity to launch as the main activity.

I had the same problem while importing a project into Android Studio, probably caused by the fact that the project has been developed on an earlier version of Android Studio than currently installed on my computer.

What solved it was simply choosing:

File -> Invalidate Caches / Restart.

and then selecting Invalidate and Restart .

If you don’t have the tab and you started with an empty activity try this. Below is a sample code example:

Now go to your AndroidManifest.xml file. Next copy the intent filter from this code. Look at your manifest file really good and paste the intent filter in the exact place it is in the code above. (after the .yourActivityName> part of the manifest.) I hope this helped.

When I clicked «Open Module Settings», there was no «Source» tab, I think because that’s been removed for newer versions of Android Studio (I’m on 0.8.14). So I had to do this instead:

Add these lines to the build.gradle file inside the android < . >block:

After editing the file, click Tools > Android > Sync Project with Gradle Files.

If you are still getting an error that says «Default Activity not found» when you try to edit the run configurations even after executing:

Invalidate cache and Restart.

Then try deleting the Settings/Preferences folder:

Following did the trick for me. From Run -> Edit Configuration.

this happened to me because I capitalized the paths in the manifest. changed:

and it was fixed

I just experienced the same error in Android Studio 1.5.1. and just found the source of the problem. I am not sure whether the cause was a human error or some strange glitch in the behaviour of the IDE, but none of the existing StackOverflow questions about this subject seemed to show anything about this so I figured I post it as an answer anyway.

For me, either one of my team members or the IDE itself, had changed the launcher activities manifest entry, causing it to look like this:

While it should, in fact, look like this:

So please double, triple, quadruple check the format of your launcher activity in the manifest and you might be able to save yourself some time.

Hope this helps.

EDIT: I strongly suggest people not to go with the answers that suggest to manually select a launcher activity inside the configuration options of your module, as this caused the application to no longer be shown in the list of installed apps on both the Samsung Galaxy S5 Neo and the Samsung Galaxy S6 (at least for me).

Comments

Copy link Quote reply

winster commented Oct 24, 2016

Since there is no activity defined in the manifest, getting error in Android studio.

Error running app:
Default Activity not found

This comment has been minimized.

Copy link Quote reply

tjohns commented Oct 27, 2016

Yes, this is correct. This is an input manager, not an activity.

You can get Android Studio not to complain by going to the «Edit Configurations» menu (tap «Shift» three times, type «Edit Configurations»), then change Launch Options > Launch to «Nothing».

I’ll probably add a generic activity containing instructions, just to avoid any confusion.

This comment has been minimized.

Copy link Quote reply

111usman commented Feb 22, 2018

This comment has been minimized.

Copy link Quote reply

iletai commented Jul 19, 2018

This comment has been minimized.

Copy link Quote reply

neilakoh commented Aug 6, 2018

I also got the same error; however, in my case it was straightforward since this error occurred in a fresh project and it turns out I have to add an intent inside activity tag to get rid of the error:

This comment has been minimized.

Copy link Quote reply

>Oct 11, 2018 •

@tjohns i agree with you that if we change that setting then app works fine but what if want to run the app without edit Edit Configuration ? I have checked this stack overflow question’s answers to solve this issue in android studio 3.2
I have spend almost 5 hours and got the solution. I have copy that project and run in another system then its working fine, So just do following solution to fix this issue and it is work for me and i hope some one will get help with this.
Solution :

  1. Delete the cash from your %Home%.gradlecash and sync project again.
  2. Also check that is there any duplicate tag in your Manifest.

This comment has been minimized.

Copy link Quote reply

hishark commented Oct 20, 2018

@AndroidNinza thank you. I spend one night to find solution, I’m trying your solution and it is downloading now, hope I can solve it and then go to bed:’-(

This comment has been minimized.

Copy link Quote reply

hishark commented Oct 20, 2018

@Andro >�� �� ��
perfect solution

This comment has been minimized.

Copy link Quote reply

JoinBelieve commented Oct 27, 2018

@IDFDeveloper thank you very mach!!

This comment has been minimized.

Copy link Quote reply

moyarich commented Nov 9, 2018

that worked really well for me. I tried file>invalidate caches/restart and that did not work for me

This comment has been minimized.

Copy link Quote reply

dav >Nov 21, 2018 •

I lost over 6 hours hunting down the problem. I even redownload gradle, restarted Android studio, Invalidated cache/restart to no vail. Until a sister pointed me to this wonderful thread.

This came to my rescue.

@tjohns i agree with you that if we change that setting then app works fine but what if want to run the app without edit Edit Configuration ? I have checked this stack overflow question’s answers to solve this issue in android studio 3.2
I have spend almost 5 hours and got the solution. I have copy that project and run in another system then its working fine, So just do following solution to fix this issue and it is work for me and i hope some one will get help with this.
Solution :

Оцените статью