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

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

问题描述

当我在Android Studio 3.3中创建新项目时,它在Run -> Edit Configurations上显示错误

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

未找到默认活动.

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

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.xml ic_launcher_background.xml ic_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天全站免登陆