简体   繁体   English

无法识别启动活动:升级到 Android Studio 4.0 后未找到默认活动

[英]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.自从在 macOS 上升级到 Android Studio 4.0 以来,我一直遇到这个问题。 When I try to start my app from Android Studio, I get the following error:当我尝试从 Android Studio 启动我的应用程序时,我收到以下错误:

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重新安装 Android Studio
  • delete all generated files and folders (build, gradle, .idea, etc)删除所有生成的文件和文件夹(构建、gradle、.idea 等)

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为了与 Mike N. 的评论相吻合,看起来这是一个需要在下一个版本中解决的问题: 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.对于快速修复的详细信息,我查看了合并清单选项卡,它位于 AndroidManifest.xml 窗格的左下角。 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:对话框说出现错误,其中 browser:1.0.0 清单的 minSdk 为 15,而我的 minSdk 的所有 rest 为 14。我点击:

use a compatible library with a minSdk of at most 14, or increase this project's minSdk version to at least 15.使用 minSdk 最多为 14 的兼容库,或将此项目的 minSdk 版本增加到至少 15。

Which brought up my minSdk to 15, and the error with the launcher went away, it will now insta-launch on my device.这将我的 minSdk 提高到 15,并且启动器的错误消失了,它现在将在我的设备上启动。 So I would sit tight for AS 4.0.1 but in the meantime, check the Merged Manifest.所以我会为 AS 4.0.1 坐稳,但与此同时,请检查合并清单。

You can solve the problem as follows:您可以按以下方式解决问题:

  1. Click your Module Selection window,then click Edit Configurations…单击您的模块选择窗口,然后单击编辑配置...

    在此处输入图像描述

  2. Then set Launch Options to Nothing ;然后将Launch Options设置为Nothing that's okay:没关系:

    在此处输入图像描述

For me this was happening in a project in which the main activity was declared in the manifest of an imported module (eg not in "app" module).对我来说,这发生在一个项目中,其中主要活动在导入模块的清单中声明(例如,不在“app”模块中)。

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>

On my side it was a issue with the manifest.就我而言,这是清单的问题。 You can detect this type of issue by watching the merged manifest tab.您可以通过查看合并的清单选项卡来检测此类问题。 For more details you can watch the link shared by Mike N. in the first comment.有关更多详细信息,您可以观看 Mike N. 在第一条评论中分享的链接。

The problem will arise in new projects when one forgets to tick the default activity checkbox during adding anyone of the first or subsequent new activity.如果在添加第一个或后续新活动中的任何一个时忘记勾选默认活动复选框,则会在新项目中出现问题。

This can be rectified at later stage by going to Run> Edit Configurations > Launch: in which change to specified activity and select the activity you choose to keep as the first page on launch of app.这可以在稍后阶段通过转到运行>编辑配置>启动来纠正:在其中更改指定活动和 select 您选择保留作为启动应用程序第一页的活动。

Try these steps:尝试以下步骤:

  1. Close Android Studio关闭 Android Studio
  2. Go to Go 至

C:\Users\my_user_name.AndroidStudio4.0\system\caches C:\Users\my_user_name.AndroidStudio4.0\system\caches

  1. Delete "caches" folder删除“缓存”文件夹
  2. Relaunch Android Studio重新启动 Android Studio

set Launch Options to ( Nothing )将启动选项设置为(

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Automotive:无法识别启动活动:未找到默认活动 - Android Automotive: Could not identify launch activity: Default Activity not found 无法识别启动活动:未找到默认活动 - Could not identify launch Activity: Default Activity not found 在构建Kotlin项目时,Android Studio报告“无法识别启动活动:找不到默认活动” - Android Studio reports “Could not identify launch activity: Default Activity not found” when building Kotlin projects “无法识别启动活动:未找到默认活动” - Android Studio - 没有答案工作 - "Could not identify launch activity: Default Activity not found" - Android Studio - no answers working 无法识别启动活动:未找到默认活动 - Could not identify launch Activity: Default Activity wasn't found 自定义键盘-无法识别启动活动:找不到默认活动 - Custom Keyboard - Could not identify launch activity: Default Activity not found 我经常发现此特定错误:“无法识别启动活动:找不到默认活动启动活动时出错” - I often found this specific error: “Could not identify launch activity: Default Activity not found Error while Launching activity” 无法识别启动活动:找不到默认活动启动活动时出错 - Could not identify launch activity: Default Activity not found Error while Launching activity 无法识别启动活动,未找到默认活动启动活动时出错 - Could not identify launch activity , Default Activity not found Error while Launching activity 运行项目时出现错误(无法识别启动活动:未找到默认活动) - Getting Error(Could not identify launch activity: Default Activity not found) While running project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM