“Default Activity Not Found” on Android Studio upgrade

后端 未结 30 1936
时光说笑
时光说笑 2020-11-22 05:08

I upgraded IntelliJ Idea from 12.0.4 to 12.10.

Now all the modules in my Android project give the error:

Error: Default Activity Not Found

相关标签:
30条回答
  • 2020-11-22 06:00

    I got this error.

    And found that in manifest file in launcher activity I did not put action and category in intent filter.

    Wrong One:

    <activity
    android:name=".VideoAdStarter"
    android:label="@string/app_name">
    
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    
    </activity>
    

    Right One:

    <activity
    android:name=".VideoAdStarter"
    android:label="@string/app_name">
    
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    
    </activity>
    
    0 讨论(0)
  • 2020-11-22 06:00

    All answers above didn't help me. Try to remove this

    <?xml version="1.0" encoding="utf-8"?>
    

    in your AndroidManifest. Then:

    File > Sync Project with Gradle Files
    
    0 讨论(0)
  • 2020-11-22 06:00

    I have the same problem in Android Studio 3.3 Canary 3. Project from Android Studio 3.0 stabile version works firstly correctly, than after some cleans/rebuilds it starts showing No Default Activity error. I tried to reinstall this alpha version of Android Studio: error again. But then started it in old stabile Android, and using apk install, and this apk works correctly.

    Moreover my project was created with Instant App (base, feature, instant, app subdirectories). I think this Android Studio has some problems with Manifest.xml files separated into this multiple directories.

    So I have changed in settings to this:

    0 讨论(0)
  • 2020-11-22 06:01

    just faced this error on android studio 2.1.2. solved by adding MAIN/LAUNCHER intent-filter to default activity in flavour manifest, though filter already was in default activity in default manifest. It even was in merged manifest, but studio can't found it until i duplicated filter in both manifests.

    0 讨论(0)
  • 2020-11-22 06:04

    In Android Studio 4.0 please change Launch to Nothing:

    Run/Debug Configuration -> Android App -> app -> General -> Launch Options -> Launch : Nothing

    0 讨论(0)
  • 2020-11-22 06:04

    I found this in my code:

    <context android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </context>
    

    If you look very carefully, it should be <activity android:name=".MainActivity"> instead.

    Apparently, I refactored an "activity" somewhere, and it changed names in the AndroidManifest as well.

    0 讨论(0)
提交回复
热议问题