Could not identify launch Activity: Default Activity not found
Asked Answered
F

18

62

I'm new to android and I have encounterded a problem. The console said that "Could not identify launch activity: Default Activity not found". I have add

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

in manifests. And I have tried Invalidate caches/Restart,still not worked. And the class file which contains the main activity turn green in android studio. I don't know what that means. This is my manifests file.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mrrobot.mycoolweather" >
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >
    <Activity       android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity"
        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>

The chooseAreaActivity is the one I want to use as launcher activity. enter image description here

Feudist answered 22/11, 2015 at 13:52 Comment(0)
M
108

For main activity in your manifest you have to add this with category LAUNCHER (First Activity on launch app):

<activity
    android:name=".MainActivity"
    android:label="YourAppName"
    android:theme="@style/AppTheme.NoActionBar" >
      <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

For other activity you have to change category to DEFAULT:

<activity
    android:name=".OtherActivity"
    android:theme="@style/AppTheme.NoActionBar" >
    <intent-filter>
            <action android:name="package.OtherActivity" />

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

Check this Activity and this Start Another Activity

So your code is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mrrobot.mycoolweather" >
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".activity.ChooseAreaActivity"
        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>
Martensite answered 22/11, 2015 at 13:56 Comment(0)
O
23

Although the question is kind of outdated, I would add the following to all the given answers:

For multi-module projects check carefully that you modify the Manifest corresponding to the Configuration you are trying to run.

Had the same problem and spent 20 minutes just to discover that I was trying to run wrong configuration (with an Application in ModulbeB, while thinking that I was running one from ModuleA).

And sometimes you are working on other module default runnable module changes so you have to change it. enter image description here

Oldster answered 13/12, 2021 at 14:52 Comment(0)
G
14

Sometimes it is solved just restarting Android Studio

Click on "File" and then "Invalidate Cache"


I had the "Default Activity not found" problem a couple of times and I could solved restarting my android Studio.

Genvieve answered 14/3, 2016 at 2:53 Comment(0)
C
6

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

File -> Invalidate Caches / Restart...
Convey answered 5/5, 2016 at 4:55 Comment(0)
C
6

In your manifest file there was wrong element name (Activity change to activity) declared

<Activity       android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </Activity>

Change it to:

 <activity       android:name="com.example.mrrobot.mycoolweather.activity.ChooseAreaActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
Caernarvonshire answered 24/1, 2019 at 9:17 Comment(1)
@JerabekJakub sometimes android studio unable to found activity and hence indexing issue occursCaernarvonshire
A
3

It is likely that the action is not in the manifest. This is the fix

Attached is an image manifest

Aberration answered 23/10, 2022 at 12:53 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Cantaloupe
M
2

When I upgraded Android Studio to 2021.1.1.23 somehow my Run Configuration was switched from app to models, producing this error. Switching back to app resolved the issue for me.

Marga answered 8/4, 2022 at 8:50 Comment(1)
I had the same problem when trying to download, build and run the ExoPlay Uamp demo program. Selecting 'app' instead of the default 'automotive' fixed that too.Hellgrammite
I
1

i had these issues with my project:

  • Default activity not found

  • xml intellisense was not working

  • kotlin standard functions were not detecting

All my above issues were resolved by Deleting System cache of Android Studio 3.3 at the home path, and it's working nicely for me,, Steps:

  1. exit Android Studio

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

  3. Then you have a \caches folder, delete this caches folder

  4. Now open Android Studio and load your project

Worked for me.. i wasted couple of hours resolving this issue and finally it got resolved in this way.

Infelicity answered 18/3, 2019 at 12:42 Comment(0)
E
1

Exit your android studio IDE. Then locate the "caches" folder in .AndroidStudio3.2 folder.

Location

C:\Users\YOUR_USERNAME\.AndroidStudio3.2\system\caches

For example.

Let's assume say YOUR_USERNAME is called Admin.

C:\Users\Admin\.AndroidStudio3.2\system\caches

Delete the caches folder and start your android studio IDE.

Egregious answered 26/3, 2019 at 10:29 Comment(0)
J
1

I have tried solutions here and other questions

  • clean & rebuild & invalidate and restart
  • make sure that activity has LAUNCHER as category
  • delete Android cache folder

at End, activity tag was has <activity android:name="com.exmaple.todo.MainActivity" /> when i changed it to <activity android:name=".MainActivity" /> app worked.

I hope it help you if other solution not work.

Janaye answered 27/10, 2020 at 10:37 Comment(0)
M
1

If your activity is in a different module (e.g. ':library) und you forgot to specify the subproject in the dependencies{} scriptblock of your :app module, the manifest of :library and therefore the activities it declares, are not imported.

dependencies {
   api project (':library')

You may check whether all activities show up in your app-debug.apk by using the following Android Studio menu command:

->Build->Analyze APK->app-debug.apk

Now open the AndroidManifest.xml and check its activity declarations.

Mestee answered 13/1, 2022 at 12:47 Comment(0)
B
1

I got this error in android 12+ after changing launch activity adding intent-filter but not make it exported.
so not forget.

           
android:exported="true"

Benignity answered 10/6, 2022 at 22:8 Comment(0)
M
0

My main activity was not declared in Android Manifest File. That's the reason which came that error. This error come because of a declaration problem of Android Manifest file. Please check it. :D

M16 answered 11/10, 2017 at 3:14 Comment(0)
D
0

This happened to me aswell took me ages to figure out why, but a weird bug I spotted is that if you run the app with breakpoints in your code without debugging mode it will cause this error to happen.

Quick fix for now: Only use breakpoints for degbugging mode.

Deduce answered 23/7, 2019 at 23:43 Comment(0)
C
0

Check your duplicate initialize activity in your AndroidManifest.xml

Like bellow:

        <activity android:name=".nim.qiaqia.lota.LotaProduct"/>
        <activity android:name=".nim.qiaqia.lota.LotaOrderDetail"/>
        <activity android:name=".nim.qiaqia.main.activity.RechargeListLotaActivity"/>
        <activity android:name=".nim.qiaqia.lota.MiningCoinLota"/>
        <activity android:name=".nim.qiaqia.lota.LotaOrderDetail"/>

that can causes ""Default Activity not found" also. So, remove it and see. its works! :)

Catarina answered 24/12, 2020 at 4:24 Comment(0)
S
0

In my case android manifest was correct. I tried to invalidate Caches and restart but not worked. Then Rebuild project and it also did not work.

Then I realized that last night I added a new library to build Gradle, it was this: implementation 'com.yalantis:eqwaves:1.0.1' And after removing this everything worked fine.

TIP: "Always have a track of things you do in your project, otherwise you will end up wasting your time"

Steepen answered 26/1, 2021 at 5:22 Comment(0)
I
0

If you only enabled building the app via app bundle, then this error might also occure when you try installing it as a default APK. Change the deployment option to APK from App Bundle and you are good to go.

Ionopause answered 12/7, 2021 at 8:58 Comment(0)
P
0

The error:

Could not identify launch activity: Default Activity not found Error while Launching activity Failed to launch an application on all devices

It can also be caused by being selected to run a module instead of the application that has the Activity set to "Launcher", you have to select the correct "app".

jorgesys Could not identify launch activity: Default Activity not found Error

Pep answered 11/10, 2023 at 21:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.