未找到默认活动 - Android Studio 3.3 中的错误 [英] Default Activity Not Found - Bug in Android Studio 3.3

查看:35
本文介绍了未找到默认活动 - Android Studio 3.3 中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Android Studio 3.3 中创建一个新项目时,它在 Run -> 处显示错误编辑配置

When I create a new project in Android Studio 3.3, it shows an error at Run -> Edit Configurations saying

未找到默认活动.

<?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 文件.它显示一行错误

This is my activity_main.xml file. It shows an error in line

tools:context=".MainActivity"

未解析的类 MainActivity

Unresolved Class MainActivity

这是我的 AndroidManifest.xml 文件 - 一切似乎都在这里 -

Here is my AndroidManifest.xml file - everything seems to be all right here -

<?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.xmlic_launcher_background.xmlic_launcher_foreground.xml 的格式不正确,看起来像这样 -

The files colors.xml , ic_launcher_background.xml, and ic_launcher_foreground.xml are not correctly formed, and look something like this -

        f

        isInitialized
        kotlin
        Boolean
        reflect

        KProperty0
        SinceKotlin
        version
        1.2
        internal

        InlineOnly0






             4"  8�H PX��     (�    �

我尝试了 Clean and Rebuild 项目,它给出了一个错误说

I tried to Clean and Rebuild project, which gave an error saying

colors.xml 格式不正确.

colors.xml is not formed properly.

我试过 File ->Invalidate Caches/Restart,但它仍然显示相同的错误.

I tried File -> Invalidate Caches/Restart, but it still shows the same error.

这个问题是在将 Android Studio 3.2.1 更新到 Android Studio 3.3 一天后开始的.第一天一切正常,但是当我尝试在第二天运行应用程序时,它开始显示此错误,提示 Default Activity not found.

This problem started one day after updating Android Studio 3.2.1 to Android Studio 3.3. It worked all fine the first day, but when I tried run an app on the second day, it started showing this error saying Default Activity not found.

有什么办法可以解决这个问题并继续使用 Android Studio 3.3 版?

Is there any way to fix this issue and continue using Android Studio version 3.3?

编辑 -

耶!正如@Andreas 所建议的那样,我的 Android Studio 本身可能已损坏,并且在卸载并重新安装相同版本后可以正常工作(我什至没有恢复到旧版本).应检查此问题是否会在几天内再次出现.

Yay! As @Andreas suggested, my Android Studio itself could've been corrupted, and works all right after uninstalling and reinstalling the same version (I did not even revert to an older version). Should check if this problem might repeat again in a few days.

编辑 2-

我在一年后查看这个,我很高兴它帮助了很多人.事实证明,这个问题可能是由各种问题引起的,对此没有一个完美的答案.因此,如果您面临同样的问题,请检查所有答案,看看是否对您有用:)

I'm viewing this after an year and I'm happy it has helped a lot of people. Turns out this problem can arise due to various issues, and there's no one perfect answer for this. So check all the answers and see if something works for you if you're facing the same problem :)

推荐答案

Android Studio 本身可能已损坏.卸载并重新安装 Android Studio 即可解决问题.

There is a chance that Android Studio itself could've been corrupted. Uninstalling and Reinstalling Android Studio solves the problem.

这篇关于未找到默认活动 - Android Studio 3.3 中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆