[英]Android Error running app: Default Activity not found
My program is giving me the following error in Android Studio.我的程序在 Android Studio 中给了我以下错误。
00:28 Error running app: Default Activity not found 00:28 运行应用程序时出错:未找到默认活动
I think the problem is in the AndroidManifest.xml我认为问题出在 AndroidManifest.xml
` `
<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=".DisplayMessageActivity"
android:parentActivityName=".MainActivity">
</activity>
</application>
` Can anyone help me please? `有人可以帮我吗?
Default Activity not found
未找到默认活动
Your application has no <activity>
that will be launched by the home screen.您的应用程序没有将由主屏幕启动的
<activity>
。 That would need to have the appropriate <intent-filter>
, such as:这需要有适当的
<intent-filter>
,例如:
<activity android:name="MainActivity">
<!-- This activity is the main entry, should appear in app launcher -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Also:还有:
Attribute parentActivityName
is only used in API level 16 and higher (current min is 15) just means that your
android:parentActivityName` attribute will not have an effect on some devices that you are supporting属性
parentActivityName
仅用于 API 级别 16 及更高级别(当前最小值为 15) just means that your
android:parentActivityName` 属性不会对您支持的某些设备产生影响
However, android:parentActivityName
is pointing to an activity ( MainActivity
) that does not exist in your manifest但是,
android:parentActivityName
指向的活动( MainActivity
)在您的清单中不存在
To correct the为了纠正
android:parentActivityName is introduced in API 16
android:parentActivityName 是在 API 16 中引入的
error, you should add this bloc of code for the activity that has a parent:错误,您应该为具有父级的活动添加以下代码块:
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.myapp.ui.MainActivity" />
Here is an example from one of my apps:这是我的一个应用程序中的示例:
<activity
android:name="com.souf.prayTime.ui.AboutActivity"
android:label="@string/about"
android:parentActivityName="com.souf.prayTime.ui.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.souf.prayTime.ui.MainActivity" />
</activity>
Hope this will help ;)希望这会有所帮助;)
The easiest way to fix this is to increase your minimum API level to 16 so that it meets the requirements for 'parentActivityName'解决此问题的最简单方法是将最低 API 级别增加到 16,以满足“parentActivityName”的要求
To do this go into your build gradle.为此,请进入您的构建 gradle。 Look for the minSdkVersion and change it to 16.
查找 minSdkVersion 并将其更改为 16。
It's at the top in android{ defaultConfig {} }它位于 android{ defaultConfig {} } 的顶部
Afterward Resync Gradle之后重新同步 Gradle
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.