当我在 Android Studio 3.3 中创建一个新项目时,它在 Run -> Edit Configurations
处显示错误
default activity is not found.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
这是我的activity_main.xml 文件。显示行错误
tools:context=".MainActivity"
说
Unresolved Class MainActivity
这是我的 AndroidManifest.xml 文件 - 一切似乎都在这里 -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.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/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>
</manifest>
colors.xml、ic_launcher_background.xml 和 ic_launcher_foreground.xml 文件格式不正确,看起来像这样 -
f
isInitialized
kotlin
Boolean
reflect
KProperty0
SinceKotlin
version
1.2
internal
InlineOnly0
4" 8�H PX�� (� �
我尝试Clean and Rebuild
项目,但出现错误提示
colors.xml is not formed properly.
我尝试了 File -> Invalidate Caches/Restart
,但它仍然显示相同的错误。
此问题是在将 Android Studio 3.2.1
更新到 Android Studio 3.3
一天后出现的。第一天一切正常,但当我在第二天尝试运行应用程序时,它开始显示此错误,提示 Default Activity not found
。
有没有办法解决这个问题并继续使用 Android Studio 3.3 版?
编辑 -
耶!正如@Andreas 所建议的那样,我的 Android Studio 本身可能已损坏,并且在卸载并重新安装相同版本后一切正常(我什至没有恢复到旧版本)。应检查此问题是否会在几天内再次出现。
编辑 2-
我在一年后查看此内容,我很高兴它帮助了很多人。原来这个问题可能由于各种问题而出现,并且没有一个完美的答案。因此,如果您遇到同样的问题,请检查所有答案,看看是否有适合您的方法:)
最佳答案
关于android - 未找到默认 Activity - Android Studio 3.3 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54319860/