android - 未找到默认活动 - 出现在我以前工作的所有项目中
问题描述
我在昨天之前工作的所有项目中不断收到此消息:“运行‘应用程序’时出错:未找到默认活动”
抱歉,我已经阅读了具有相同问题的类似帖子,但还没有找到解决方案。这不是清单文件,因为我已经将它们与其他帖子中的文件进行了比较。大约一周前,我已经完成了两个项目,但现在也无法正常工作。
构建 --> 清洁项目不起作用。
我也尝试过两三次:File---->Invalidate Caches/Restart。单击它并选择 Invalidate Caches/Restart
我昨天安装了更新。我不知道该怎么做,我将不胜感激任何帮助/反馈。我是android studio的新手,所以请随意过度简化哈哈。:)
这是我通过 Udacity 课程制作的项目在 AndroidManifest.xml 中的代码。这个与其他项目有相同的错误:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.birthdaycard">
<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">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这是来自一个新项目的 Android Manifest 文件(比较两个玩具 - 是的,我是一个收集玩具的成年人,哈哈)同样的问题:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.example.newapplication">
<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>
<activity android:name=".BarbieOne">
</activity>
<activity android:name=".BarbieTwo">
</activity>
</application>
这是同一项目的 build.gradle (Module:app) - 抱歉,不确定这是否是正确的构建 gradle 文件
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "android.example.newapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
}
解决方案
兄弟让我先解释一下你的问题。几个月前,我遇到了同样的问题,这意味着您想运行您的应用程序,但构建显示错误,例如未找到默认活动。虽然在这个问题之前你的代码运行得很好。我知道你尝试了很多答案,但在新的工作室可能来自 3.0 这个问题可能会发生。有时工作室不会从应用程序的清单文件中读取你的启动器代码。好的,现在你有两个选择。
在此之前,请再次尝试重建、无效和清理项目。
First Choice 尝试添加一个或两个新 Activity 并使它们一个一个启动器可能是 android studio 在清单文件中读取您的启动器代码,您可以运行您的应用程序。
注意:它只对你的运气有效。
第二个选择 您可以将代码粘贴到新项目中。
注意:这是最后一个选项。
希望你好运。
推荐阅读
- postman - 邮递员错误:证书链中的自签名证书
- python - Pandas 按组的所有值的总和进行分组,另一列以逗号分隔
- javascript - 函数调用如何在 javascript 中工作?
- c - 我不明白将 4 字节地址插入数组的代码的数据类型
- html - 使用 CSS 从头开始样式形状?
- powershell - 如何防止 PowerShell 将异常数据添加到 $error
- sas - PROC LOESS 选项 MAXPOINTS = NONE
- ios - iOS/Swift:SecItemCopyMatching 为 biometryCurrentSet 的访问控制产生 errSecParam (-50) 状态
- excel - VBA:如果ID匹配,则在单个单元格中返回多个值
- html - 如何使用 Unix 从文件中删除未使用的 html 代码