简体   繁体   English

运行应用程序的Android错误:未找到默认活动

[英]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.

相关问题 运行“应用程序”时出错:在 Android Studio 中找不到默认活动 - Error running 'app': Default Activity not found in Android Studio 找不到默认活动,运行应用程序时出错 - Default Activity not Found, Error Running App Android Studio 无法运行导入的项目(Error running &#39;app&#39; default activity not found - Android Studio can't run imported projects (Error running 'app' default activity not found 如何修复“运行‘应用程序’时出错:未找到默认活动” - How to fix "Error running 'app': Default Activity not found" 运行“java”时出错:在 android studio 中找不到默认活动 - Error running 'java': Default Activity not found in android studio 错误:包含广播接收器的应用程序的“未找到默认活动” - Error: 'Default Activity Not Found' for an app containing a Broadcast receiver 找不到Android清单默认活动 - Android Manifest Default Activity not found Android-找不到默认活动 - Android - Default Activity Cannot Be Found 运行任何新的android项目时出现问题-找不到默认活动/无效的Java包 - Issues running any new android project - Default Activity Not found / Invalid Java package Android Automotive:无法识别启动活动:未找到默认活动 - Android Automotive: Could not identify launch activity: Default Activity not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM