欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Android 报错Could not identify launch activity

程序员文章站 2022-04-25 08:24:13
...

第一次编译Android Studio难免会发生一些问题,比如AS报错提示如下:
Could not identify launch activity: Default Activity not found Error while Launching activity

这是因为AndroidManifest.xml里面没有设置运行初始的activity

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            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>

一般都是漏了这句android:label="@string/app_name",补上重新运行就好了。

相关标签: Android 报错