“Default Activity Not Found” on Android Studio upgrade

后端 未结 30 1897
时光说笑
时光说笑 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 05:46

    I found this blog that really fixed this issue in my case. It turns out you have to add some sort of intent:

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

    It was definitely straightforward. Reference:

    https://www.aboutonline.info/2018/08/error-running-app-default-activity-not-found-on-android-with-kotlin.html

    0 讨论(0)
  • 2020-11-22 05:47

    The correct way to do this is to add the following to the Manifest file:

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

    This should be inserted between:

    <application> </application>
    

    No need in invalidating caches.

    0 讨论(0)
  • 2020-11-22 05:47

    Firstly make sure that you have included default activity in manifest.

    Example:

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

    If you have tried everything and nothing seems to works then

    • Delete the cache from your %Home%\.gradle\caches and sync project again.

    Or check this answer

    https://stackoverflow.com/a/53476487/5507705

    0 讨论(0)
  • 2020-11-22 05:48

    As this question is a "landing page" for plethora of issues with manifest, resulting in no Default Activity found, here is another thing to check if you are having this problem.

    Open your Manifest and switch to Merged Manifest tab.

    Sometimes the issue is related to merging all the manifests in the project to one, which can result to error and therefore "Default Activity not found". The problem is this error is not shown anywhere except this Merged Manifest tab as far as I know.

    Es: in a project minSdkVersion 10, downgrade the version of implementation in build.gradle file: from 25.4.0 to 25.3.1 solve this problem.

    dependencies {
    implementation 'com.android.support:appcompat-v7:25.3.1'   
    implementation 'com.android.support:design:25.3.1'         
    implementation 'com.android.support:mediarouter-v7:25.3.1' 
    

    0 讨论(0)
  • 2020-11-22 05:48

    In case your application doesn't have an Activity (only a service for example), change the run/debug configuration 'Launch' option to Nothing.

    0 讨论(0)
  • 2020-11-22 05:49
    1. Build -> Rebuild Project
    2. File -> Invalidate Caches.. -> Invalidate and restart

    It works for me. Rebuild project to make sure that no errors in project. Then we can invalidate cache.

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