【问题标题】:Default activity not found error when following Android Studio beginner guide遵循 Android Studio 初学者指南时未找到默认活动错误
【发布时间】:2019-12-25 13:05:33
【问题描述】:

我正在尝试添加向上导航,同时遵循 android studio here 的初学者教程。但是,当我尝试运行它时,它给了我错误:

Error running 'app':
Default Activity not found

我的AndroidManifest.xml 文件中的代码是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp">

<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">
        <!-- The meta-data tag is required if you support API level 15 and lower -->
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity" />
    </activity>

</application>

</manifest>

【问题讨论】:

标签: android android-manifest intentfilter


【解决方案1】:

这里可能会发生很多事情。我首先建议您以敏锐的眼光检查所有对布局的命名引用和背后的代码。有时通过编辑,您可能会通过添加或删除名称中的字母来无意中更改和重命名文件。此外,有时在使用 IDE 时,修改状态可能会过时,您有时可以在其中执行清理/构建或重新启动 IDE。 IDE 的未决更新也可能是罪魁祸首。

作为最佳实践,您应该对代码进行版本控制。这将有助于缓解诸如此类的大多数问题。查看以下链接,了解 Android 对此做法的建议。

https://developer.android.com/studio/publish/versioning

【讨论】:

    猜你喜欢
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-13
    • 2016-10-03
    • 2010-11-25
    相关资源
    最近更新 更多