0

Before hurrying to mark duplicate this question please read it entirely.Thank you

I ran into a problem with my Android Studio. While was testing my application I got an error(bad coding) and after I tried to run app again I got error Default activity not found.
After that I searched for answers about that error but after 2 hours I gave up, tried everything I found: check manifestxml file, invalidate and restart option ,sync gradle files , nothing worked out. So I decided to make a new project and copy everything from that project to the new one but first wanted to make sure that it is working as it is now, a brand new project and the surprise was no, is not running, and the error is the same.Please help me out.

AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gabriel.android">
<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>

build.gradle module app

    apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
    applicationId "gabriel.android"
    minSdkVersion 23
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.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'
}

build.gradle project top-level file

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
  }
GianhTran
  • 3,443
  • 2
  • 22
  • 42
  • 1
    Did you actually use `MainActivity` as the name of your entry file? – Keheira Jan 10 '19 at 20:36
  • @Keheira For testing purposes why it matters so much what is the name of a file ? –  Jan 10 '19 at 20:39
  • You might wanna check your activity name, which you want to show up when you open the app. And make sure you name it correct in the `Manifest.xml` file in place of `.MainActivity` if it is not the same name – Alok Jan 10 '19 at 20:39
  • because you might have used a different file name and thus it's unable to connect the 2 – Keheira Jan 10 '19 at 20:40
  • @Alok I did check that, is the same name , as I said in the post I checked manifest file... –  Jan 10 '19 at 20:40
  • @Keheira I think is not the case –  Jan 10 '19 at 20:43
  • Can you show me the `MainActivity` class in your code @user3720015? – Alok Jan 10 '19 at 20:45
  • @Alok At this moment I did a clean unninstall and I am installing AndroidStudio again, but it's the common code for an android application, like the code from here : https://www.javaworld.com/article/3104621/mobile-java/android-studio-for-beginners-part-2-explore-and-code-the-app.html –  Jan 10 '19 at 20:48
  • what does your file structure look like? – Keheira Jan 10 '19 at 20:49
  • build scripts with gradle files and app folder : build , libs , src . In src : androidTest , test, main . In main : AndroidManifest.xml and java and res folder . In java folder is package name and in package name are java classes –  Jan 10 '19 at 20:58
  • Ok seems like uninstalling and installing back the AndroidStudio worked out –  Jan 10 '19 at 22:43

1 Answers1

0

Following steps here to properly delete Android Studio and installing it again solved my problem.