Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not identify launch activity: Default Activity not found after upgrading to Android Studio 4.0

I've been having this problem since upgrading to Android Studio 4.0 on macOS. When I try to start my app from Android Studio, I get the following error:

Could not identify launch activity: Default Activity not found
Error while Launching activity

What's a bit unique about my project is that the default activity is defined in the manifest of another library used by my project, not the project itself. This was all working fine before the upgrade, but now it isn't for me. When I open the project containing the dependency, it builds and runs fine. I've already tried the following steps:

  • clean the project, rebuild
  • invalidate caches and restart
  • reinstall Android Studio
  • delete all generated files and folders (build, gradle, .idea, etc)
like image 463
user2970752 Avatar asked Jun 03 '20 16:06

user2970752


3 Answers

You can solve the problem as follows:

  1. Click your Module Selection window,then click Edit Configurations…

    enter image description here

  2. Then set Launch Options to Nothing; that's okay:

    enter image description here

like image 153
chaoqiang li Avatar answered Oct 12 '22 09:10

chaoqiang li


To dovetail off of Mike N.'s comment, it looks like it is an issue to be resolved in the next point release: https://issuetracker.google.com/issues/158019870

For the details of the quick fix, for me I looked at the Merged Manifest tab, which is at the bottom-left of the AndroidManifest.xml pane. This shows all of the library manifests combined with your activity's.

The dialog said an error occurred where browser:1.0.0 manifest had a minSdk of 15 whereas all the rest of my minSdk are 14. I clicked on:

use a compatible library with a minSdk of at most 14, or increase this project's minSdk version to at least 15.

Which brought up my minSdk to 15, and the error with the launcher went away, it will now insta-launch on my device. So I would sit tight for AS 4.0.1 but in the meantime, check the Merged Manifest.

like image 21
A13X Avatar answered Oct 12 '22 09:10

A13X


For me this was happening in a project in which the main activity was declared in the manifest of an imported module (e.g. not in "app" module).

The solution for me was to add again the activity declaration in the manifest file of my top project:

<activity android:name="com.cristian_slav.elements.MainActivity"
          android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
like image 36
Cristi Slav Avatar answered Oct 12 '22 11:10

Cristi Slav