简体   繁体   English

Android Studio:运行“ app”默认活动时出错

[英]Android Studio : Error running 'app' Default activity not found

I'm new to android studio and doing my first project. 我是android studio的新手,正在做我的第一个项目。 I made changes to my layout xml file after which getting the above mentioned error. 我对布局xml文件进行了更改,然后收到上述错误。 i didn't add any new activity and also the android manifest.xml file has default activity mentioned. 我没有添加任何新活动,并且android manifest.xml文件中提到了默认活动。

I have tried to invalidate the cache and restart the Android studio but still the error exists and I'm not able to execute my program. 我试图使缓存无效并重新启动Android Studio,但仍然存在该错误,并且我无法执行我的程序。

In this scenario You have missed by telling the manifest about Which activity to run, Like I have Removed these Lines From Menifest 在这种情况下,您错过了告诉清单有关运行哪个活动的信息,就像我从清单中删除了这些行一样

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

This error will accour, Just add the above Lines in menifest and Your error will Gone. 将会出现此错误,只需在清单中添加上述行,您的错误就会消失。

Like I have tested By removing the above line for Yourself from Menifest I face the Error just Like You.. 就像我已经测试过一样,从清单中删除了上面的代码,就像您一样面对错误。 错误图片

Here the main Activity will be the One You want to start First After Installation Of Apk 在这里,主要活动将是您要在安装Apk之后首先开始的活动

You can configure it from "app" -> "Configurations" 您可以从“应用”->“配置”进行配置 在此处输入图片说明

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM