“Default Activity Not Found” on Android Studio upgrade

后端 未结 30 1935
时光说笑
时光说笑 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:07

    Nothing above helped me. After some time I found that IDEA changed action names to uppercase. Like:

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

    After reverting to normal, IDEA recognizes default activity:

    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
    0 讨论(0)
  • 2020-11-22 06:07

    In my case File -> Invalidate Caches / Restart... didn't help

    Everything was ok with my project and of course I had next intent filter for my activity

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

    What really helped me is deleting Android/Gradle cache folders (they can grow up to 10-30 GB)

    Go to C:\Users\YOUR_USER_WINDOWS_NAMEand delete next folders

    • .android
    • .AndroidStudio3.2
    • .gradle

    (you may save some Android configs from .AndroidStudio3.2 before deleting it if you want it)

    You can create bat file CLEAR_CACHE.cmd like this to delete folders without Recycle Bin

    rmdir /S /Q .android
    rmdir /S /Q .AndroidStudio3.2
    rmdir /S /Q .gradle
    

    it would work much faster and you don't have to delete it also from Recycle Bin

    p.s. put CLEAR_CACHE.cmd into C:\Users\YOUR_USER_WINDOWS_NAME

    it's also a good idea to delete Android Studio folder and download it again

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

    I changed my Intent-filter to

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

    Just add DEFAULT option as well. I was using the Process Phoenix library and it prompted me to define a default intent. This addition solved my problem.

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

    This occurred to me after my PC restarted unexpectedly.
    Strangely, I had made no changes and still got this error.
    None of the above helped me. What solved my problem, is this.
    Step 1:


    Step 2:


    Step 3:

    If this doesn't solve the problem give other tries.

    Try 1:

    File -> Invalidate Caches / Restart...
    

    Try 2:
    check whether these following two lines

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

    are in your launcher activity declaration in manifest.xml

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

    Try 3:

    1. Click as shown:

    2. Run / Debug Configurations opens.





    if this also doesn't help.
    Try 4:

    1. File->Export to ZIP.
      and
    2. Import it as new project.

    Best luck.

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

    100% working

    You must be seeing this

    First open your manifest and check if this present,

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

    If not present add it

    If the above is present but still you see default activity not found.

    Follow these steps:

    1. Click edit configuration

    2. On clicking edit configuration you'll see that launch option is set on DEFAULT ACTIVITY

    1. Change it to nothing.

    Problem solved!

    Happy Coding.

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

    @TouchBoarder almost had it. Although selecting "Do not launch Activity" results in nothing launching.

    In Android Studio under Run/Debug Configuration -> Android Application -> General -> Activity -> select the option "Launch:"

    Choose your Activity. This doesn't exactly fix the intended behaviour but rather overrides it correctly.

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