Error while launching activity android studio

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

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

Milad Faridnia's user avatar

asked Nov 22, 2015 at 13:52

Jiawei Yang's user avatar

0

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>

answered Nov 22, 2015 at 13:56

Michele Lacorte's user avatar

Michele LacorteMichele Lacorte

5,2246 gold badges32 silver badges53 bronze badges

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

behrad's user avatar

behrad

1,16813 silver badges21 bronze badges

answered Dec 13, 2021 at 14:52

frumle's user avatar

frumlefrumle

5265 silver badges15 bronze badges

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.

answered Mar 14, 2016 at 2:53

Orlando Herrera's user avatar

Orlando HerreraOrlando Herrera

3,4631 gold badge33 silver badges44 bronze badges

0

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

answered May 5, 2016 at 4:55

Mahendran Candy's user avatar

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>

answered Jan 24, 2019 at 9:17

Rohit Kumar's user avatar

Rohit KumarRohit Kumar

6358 silver badges13 bronze badges

1

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.

answered Apr 8, 2022 at 8:50

rwst's user avatar

rwstrwst

2,4562 gold badges28 silver badges35 bronze badges

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:UsersYOUR_WINDOW_USER_NAME.AndroidStudio3.3system

  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.

answered Mar 18, 2019 at 12:42

Shoaib Mushtaq's user avatar

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

Location

C:UsersYOUR_USERNAME.AndroidStudio3.2systemcaches

For example.

Let’s assume say YOUR_USERNAME is called Admin.

C:UsersAdmin.AndroidStudio3.2systemcaches

Delete the caches folder and start your android studio IDE.

Nelson Katale's user avatar

answered Mar 26, 2019 at 10:29

Navin Kumar's user avatar

Navin KumarNavin Kumar

2,9073 gold badges19 silver badges43 bronze badges

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.

answered Oct 27, 2020 at 10:37

Mahmoud Mabrok's user avatar

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.

answered Jan 13, 2022 at 12:47

roplacebo's user avatar

roplaceboroplacebo

2,8072 gold badges16 silver badges19 bronze badges

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"

answered Jun 10, 2022 at 22:08

nima moradi's user avatar

nima moradinima moradi

2,13018 silver badges31 bronze badges

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

Attached is an image manifest

Thomas Smyth - Treliant's user avatar

answered Oct 23, 2022 at 12:53

David Martin's user avatar

1

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

answered Oct 11, 2017 at 3:14

chamiya's user avatar

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.

answered Jul 23, 2019 at 23:43

dave o grady's user avatar

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! :)

answered Dec 24, 2020 at 4:24

Izzamed's user avatar

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»

answered Jan 26, 2021 at 5:22

Vijay's user avatar

VijayVijay

1,0858 silver badges22 bronze badges

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.

answered Jul 12, 2021 at 8:58

bd1909's user avatar

bd1909bd1909

851 silver badge6 bronze badges

Whenever we try to launch an activity we encounter the error “Error type 3: Activity class {} does not exist” in the Android Studio. The MainActivity Page throws the error as:

Error while executing: am start -n “LauncherActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

Starting: intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=”LauncherActivity”}

Error type 3

Error: Activity class {LauncherActivity} does not exist.

Error while Launching activity

Due to this error, you must be unable to launch your launcher activity for your project if you uninstalled it on the device. So in this article, we are going to discuss that why does this error occurs and six methods that will help you to solve this error.

Why There is a Need to fix “Error type 3 Error: Activity class {} does not exist” in Android Studio?

When you have connected your device/emulator and you run the app from Android Studio. After testing your application, you uninstalled it from the device while it is still connected to the system and you just tried to rerun the application from Android Studio. The MainActivity page in the project reports an error because android studio thinks that your project is still running on the phone, but you uninstall it, but it doesn’t know it, thinking that your project’s MainActivity is still in progress, So it cannot be installed. So we need to fix this issue as this error keeps interrupting while launching the application via Android Studio.  

Now the point that comes here is how we can Fix “Error type 3 Error: Activity class {} does not exist” in Android Studio. So in this article, we are going to discuss five different methods to Fix “Error type 3 Error: Activity class {} does not exist” in Android Studio. 

Method 1

Step 1: Try to clean your project and delete the build directory

To clean your project navigate to Build > Clean Project

Step 2: Restart Android Studio and Rebuild your Project 

To rebuild your project just go to Build > Rebuild Project

Step 3: Now just click on the “Invalidate Caches/Restart” option from the File in the left top corner. Finally uninstall the app on your device and try again to launch it.

Method 2

Try to delete Gradle Cache. If you don’t know where is the Gradle cache is located, you may look for:

  • On Windows: %USERPROFILE%.gradlecaches
  • On Mac / UNIX: ~/.gradle/caches/

Method 3

To completely remove and reinstall the app from your device, you just need to type these code:

adb uninstall <package_name> in terminal. 

Write your own package name in place of package_name

Method 4

If multiple users are set up on your device or in a case while testing the app on a device and you are trying to delete the app from your device. Then in this case the app doesn’t uninstall properly. Then follow this:

  • Simply go to your Device (Mobile) Settings > Apps > [Your_App] > More > Uninstall App for All Users
  • Now try to install and launch your app again.

Method 5

You can use the ./gradlew uninstallAll command instead of uninstalling the (just dragging to uninstall) app from your device .

My team and I have been very excited about Google’s new release of Android Studio 3.1. We have decided to upgraded from Android Studio 3.0.1 to it immediately once it was available in Stable channel without expecting any major problems. Little did we know,

http://www.quickmeme.com/meme/3sghsd

http://www.quickmeme.com/meme/3sghsd

Stable release from Google doesn’t always mean bug free

I am going to discuss about my experience with Google’s Android Studio 3.1.; what’s new about it, what are the issues to expect, and how my team and I have managed to solve them.

Let us begin with Android Studio 3.1. new main features:

  • C++ performance profiler : helps troubleshoot performance issues in app code.
  • Better code support editor in SQL table and query creation statements for Room or SQLite database
  • Added better lint support for Kotlin code

For more new features see: Release Note

Here are some issues we encountered after upgrading to Android Studio 3.1:

Issue #1: “Run” not compiling code

OR

Issue #2: Session ‘app’: Error Installing APK

These two issues (#1 and #2)seem to appear like bugs. The reason behind is either the code does not compile or Android Studio has failed to install the app.

Suggested solution: manually add Gradle-aware Make in Run/Debug Configuration.

Select Run and click Edit Configurations

Make sure, Gradle-aware Make is Added in TaskList or not. If not then:

  • click +
  • select Gradle-aware Make
  • Leave the task empty and select OK

NOTE: Make sure Gradle-aware Make is before Instant App Provision

Issue #3: APK file does not exist on disk

What happened here is because APK file has not been created and there is no error message to show. So, in order to see what went wrong, click on Toggle View on the left side menu (see image below). You will see a list of error messages.

Note: Some might suggest to disable Instant Run. It might help in some cases. However we need to keep in mind that Instant Run is one of the most useful features in Android Studio to speed up build process.

Bonus

Here are some solutions to try out if you are having problems building Android project (not just on Android Studio 3.1):

  • Sync / refresh Gradle
  • Build → Rebuild
  • File → invalidate caches / restart
  • Delete .gradle folder

(Please note that you can try either one of the solution. You might not need to do all of them in this order.)

Note: Don’t worry, this .gradle folder will be generated automatically by Android Studio after your Gradle is synced successfully. In some cases, you might need to delete .gradle folder and re-sync it to make sure your Gradle is updated successfully.

Update #1

There was a situation when I ran my app in Android Emulator, and I tried to attach debug, my application crashed.

First Solution:
Restart your Android Emulator or use another Android Emulator.

Second solution: Cold boot your Android Emulator
In Android Studio Menu Bar, select ToolAVD Manager then find your Android Emulator. In Actions column, select drop down icon then click on Cold Boot Now.

I will keep this article updated.

Update #2

Issue: app module cannot be built with the error message below.
Error: please select Android SDK.

Solution:

Here the steps that I found in StackOverflow that worked:

  1. File — > Invalidate Caches — > Invalidate
  2. File — > Close Project.
  3. Remove the project from the AS project selector window.
  4. Quit from Android Studio
  5. Start Android Studio and open project again

Update #3

Issue: I encountered below issue when try to build the app.

Circular dependency between the following tasks:
:compileTestGroovy
+--- :compileTestJava
|    --- :compileTestGroovy (*)
--- :compileTestScala
     --- :compileTestJava (*)

(*) - details omitted (listed previously)

Solution: Disable Instant Run did the trick.

Update #4

Issue: I encountered below issue when try to build the app.

android studio Run Configuration Error: Broken configuration due to unavailable plugin or invalid configuration data.

Solution: Make sure android support plugin is checked in plugins section under preferences.

Update #5

Issue: I encountered below issue when try to build the app.

Write access is allowed from event dispatch thread only

Solution: Seems like android studio conflicted with my installed JDK version, so I need to make sure to use embedded JDK version in android studio SDK Location.

Update #5

Issue: I had below issue when try to build the app.

buildOutput.apkData must not be null

Solution: clean and re-make the android project.

Build -> Clean Project

Build -> Make Project

Update #6

Issue:

Error while executing: am start -n “SplashActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=SplashActivity }
Error type 3
Error: Activity class {SplashActivity} does not exist.

Error while Launching activity

Possible cause:

  • You installed the current app to different user. you can have owner user and guest user or more user as you added

So if you install the app for owner and try to re-install the app for Guest user, you will see the error.

Solution:

Switch to the user where the app was install before re-install the app, or delete the old app from the unwanted user.

  • Another cause is that your application was not properly uninstalled.

Solution:

You can go to setting -> Apps & notifications -> select the app -> then uninstalled the app

Update #7

Issue:

Sometime, when I run the Android emulator, I do not see any logs in logcat; at the end of the log, there’s an error:

Solution:

In the emulator, go to developer options and set logger sizes per log buffer to max, in my case I set to 16M.
Then restart android emulator. Refer to images below as references:

Update #8

Issue:

Error running ‘app’: Default Activity not found

Solution:

Option 1: Clear cache folder inside AndroidStudio and rebuild your project.

Option 2:

  • Go to Edit Configuration
  • -> Select your Application Module
  • -> Under Launch Options
  • -> Select Nothing from Launch drop down.

Update #9

Issue:

Error: Failed to open zip file.

Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync product (requires network)

Solution:

  • Delete all gradle folder in:

Linux or Mac: ~/.gradle/wrapper/dists

(~ is the home directory)

Windows: C:Users{user-name}.gradlewrapperdists

  • Restart Android Studio

Понравилась статья? Поделить с друзьями:
  • Error while installing my summer car
  • Error while injecting payload rc 50
  • Error while injecting dll into target process 3d analyzer что это
  • Error while initializing opengl diablo 3
  • Error while connecting to host 10061