[英]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:
我已经尝试了以下步骤:
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:您可以按以下方式解决问题:
Click your Module Selection window,then click Edit Configurations…单击您的模块选择窗口,然后单击编辑配置...
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:尝试以下步骤:
C:\Users\my_user_name.AndroidStudio4.0\system\caches
C:\Users\my_user_name.AndroidStudio4.0\system\caches
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.