0

I keep getting this message on all of my projects which were previously working as of yesterday: "Error running 'app': Default Activity not found"

Sorry, I've read similar posts with the same issue but haven't figured out a solution. It's not the Manifest files because I've compared them to the ones in other posts. I've pulled up two projects from about a week ago and those won't work now either.

Build --> Clean Project didn't work.

I've also tried this two or three times: File---->Invalidate Caches/Restart. Click on it and choose Invalidate Caches/Restart

I installed an update yesterday. I'm not sure what to do, I'd appreciate any help/feedback. I'm new to android studio, so please feel free to over simplify lol. :)

Here's the code I have in the AndroidManifest.xml through a project I made through a Udacity course. This one has the same error as the other projects:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.birthdaycard">

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

Here's the Android Manifest file from a new project (comparing two toys - yes, I'm an adult who collects toys lol) same issue:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.example.newapplication">

<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"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".BarbieOne">
    </activity>
    <activity android:name=".BarbieTwo">
    </activity>
</application>

Here's the build.gradle (Module:app) for the same project - Sorry, not sure if this was the right build gradle file

    apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "android.example.newapplication"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android- 
optimize.txt'), 'proguard-rules.pro'
   }
 }
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso- 
core:3.0.2'
}
Rae
  • 1
  • 1
  • Hmm, odd! Could you please edit your question to include the AndroidManifest.xml and build.gradle files from the most recent affected project? – stkent May 11 '19 at 19:18
  • Did you maybe define an Activity as DefaultActivity in your Run Configuration under "Launch Options"? (`Run -> Edit Configuration...`) – muetzenflo May 11 '19 at 20:48
  • Just checked. Yes, both are set to DefaultActivity. – Rae May 11 '19 at 20:59
  • What happens when you open the layout xml file for that default Activity? Can you open it? – Erik May 11 '19 at 21:06
  • I'm able to open the activty_main.xml from layout in Android Studio. I don't see any errors/anything listed in red – Rae May 11 '19 at 21:16
  • Possible duplicate of [Error: Default Activity Not Found](https://stackoverflow.com/questions/15825081/error-default-activity-not-found) – Erik May 11 '19 at 21:23
  • I've tried invalidate caches but didn't work – Rae May 11 '19 at 21:35
  • I tried creating a new project, and I get the same message(Default Activity not found) before adding anything to it. Maybe I should copy my files, uninstall and reinstall android studio? – Rae May 11 '19 at 22:04

1 Answers1

0

Bro Let me explain first about your problem. Few months ago I faced same problem that's mean you want to run your app but build shows error like Default Activity not found. while before this problem your code was running very well.I know you tried lots of answer but in new studio may be from 3.0 this problem may be occurred.Some time studio does not read your launcher code from manifest file of app. OK now you have two choices.

Before this try to Rebuild, Invalidate and clean project one time again.

First Choice Try to add one or two new activity and make them launcher one by one may be android studio read your launcher code in manifest file and you can run your app.

Note: It works only your luck.

Second choice You can copy your code paste in new project.

Note: This is last option.

Hope so You have great luck.

BlackBlind
  • 772
  • 9
  • 26