Default Activity Not Found - Bug in Android Studio 3.3

Umesh Konduru picture Umesh Konduru · Jan 23, 2019 · Viewed 11.8k times · Source

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>

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

tools:context=".MainActivity"

saying

Unresolved Class MainActivity

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>

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��     (�    �

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

colors.xml is not formed properly.

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

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.

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

EDIT -

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.

EDIT 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 :)

Answer

Astha Garg picture Astha Garg · Jan 23, 2020

After searching a lot this is what worked for me,

Go to Edit Configuration -> Select your Application Module -> Under Launch Options -> Select Nothing from Launch drop down.

(Refer image for better reference) enter image description here