【问题标题】:Could not identify launch activity: Default Activity not found Error while Launching activity. kotlin无法识别启动活动:启动活动时未找到默认活动。科特林
【发布时间】:2021-09-09 04:45:04
【问题描述】:

新的android studio版本android-studio-2021.1.1.11,尝试创建示例空Android应用程序,它显示此错误。

我正在用 KOTLIN 尝试这个

无法识别启动活动:未找到默认活动

启动活动时出错。

AndroidManifest.xml 包含以下内容:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.myapplication">      <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/Theme.MyApplication" />  </manifest>

解决该错误的任何解决方案,由于该错误,android 应用程序无法打开。

我是初学者。请详细给出解决方案

【问题讨论】:

  • 您是否在 Manifest 文件中添加了您的活动?

标签: java android android-studio kotlin


【解决方案1】:
**Check your manifest.. you are probabaly missing the intent filter that I have shown in snippet.**

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

【讨论】:

  • 您好,感谢您的回复,我是全新的,我一开始没有选择任何活动,所以现在我选择了空活动,现在它正在工作,非常感谢您的回复。
【解决方案2】:

您需要在清单文件中声明您的活动。

<application
        android:allowBackup="false"
        android:icon="@drawable/logo"
        android:label="App Name"
        android:roundIcon="@drawable/logo"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:usesCleartextTraffic="true"
        tools:replace="android:theme,android:allowBackup,android:label"
        tools:targetApi="m">

        <activity android:name="com.app.ui.YourActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

  // Your other activities go here

【讨论】:

  • 您好,感谢您的回复,我是全新的,我一开始没有选择任何活动,所以现在我选择了空活动,现在它正在工作,非常感谢您的回复。
  • 如果它有效并帮助了你,那么不要忘记接受并投票;)
猜你喜欢
  • 2017-01-28
  • 2016-02-24
  • 2016-11-17
  • 2020-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-04
相关资源
最近更新 更多