Run -> Edit Configurations
当我在 Android Studio 3.3 中创建一个新项目时,它会显示错误提示
未找到默认活动。
<?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"
说
未解决的类 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 格式不正确。
我试过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-
一年后我正在查看这个,我很高兴它帮助了很多人。事实证明,这个问题可能由于各种问题而出现,并且没有一个完美的答案。因此,请检查所有答案,如果您遇到同样的问题,看看是否对您有用:)