amodkanthe
amodkanthe

Reputation: 4530

Android Studio 4.0.1 default activity not found

I am using android studio 4.0.1 facing following issue

enter image description here enter image description here

Tried File -> Invalidate caches / Restart this works once. Works for first run only on restart when I try to run it second time it again shows error default activity not found.

Also tried Edit Configurations... set Specified activity strange issue found it says activity not found in manifest

enter image description here

Here is code from manifest

        <activity
        android:name=".config.SplashActivity"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Splash">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="domain.com"
                android:pathPrefix="/"
                android:scheme="https" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />

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

        <!-- Branch App Links (optional) -->
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="domain.app.link"
                android:scheme="https" />
            <data
                android:host="domain.app.link"
                android:scheme="https" />
        </intent-filter>
    </activity>

Update: Also tried File -> Sync Project with Gradle files not working. It is working only once start or restart android studio for second run this issue occurs

Update : Tried updating android studio to new version 4.0.2 still facing the same issue

Upvotes: 1

Views: 1581

Answers (7)

Vanshaj Daga
Vanshaj Daga

Reputation: 2165

This same issue happened to me couple of days back and was corrected by using the complete name of my activity including my package name in the manifest file (Strange issue). So in your case use

<activity
        android:name="com.my_package.android.config.SplashActivity" //<---this line
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Splash">

This process worked for me after 2 tries and after that there is no issue till date.

Upvotes: 0

chen
chen

Reputation: 192

try delete .idea folder or use gradlew build at Terminal

Upvotes: 0

anwar alam
anwar alam

Reputation: 602

First You need to close your android studio Then do this

deleting :

 1 .android

 2 .AndroidStudio

 3 .gradle

from C:\Users[your user name]

Start Android studio ( Will take some time to rebuild)

Upvotes: 0

Maulik Hirani
Maulik Hirani

Reputation: 1913

You should give this a try:

  • Close Android Studio.
  • Delete C:\Users\username\.AndroidStudio4.x\system\caches folder.
  • Try running the build again.

Upvotes: 0

Perraco
Perraco

Reputation: 17360

Next a list of different actions you can try. Each entry in the list is a completely different solution independent from each other:

  1. Check your manifest for merge errors. Open your manifest and at the bottom select the Merged Manifest button. Sometimes such problems are caused by merging conflicts:

enter image description here

  1. Ensure your manifest activity has the next intent filter:

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>`
    
  2. Edit your "Run / Debug Configurations". Change the "Launch" to "Default Activity". If your activity isn't the default one, then change back to "Specified Activity" but select it from the right menu button "the 3 dots button", and do not type manually the activity name.

  3. Edit your "Run / Debug configuration". At the bottom of the "general" tab remove the "Gradle-aware Make" entry. Apply it and exit this window. Build your project, then open again "Run / Debug configuration", and add again the "Gradle-aware Make" entry.

  4. Delete obsolete Android Studio data folders from previous installations. Under your folder "C:\Users\<Your user name>\", remove any older Android Studio folder from previous installations.

  5. "Clean" your project using the option in the "Build" menu, and also use the "Invalidate Caches / Restart" option in Android Studio's File menu.

  6. Do not qualify your activity in the manifest tag, so in your case leave it as:

    android:name=".SplashActivity"
    
  7. Do the opposite of solution 7, so fully qualify it:

    android:name="com.my_package.android.config.SplashActivity"
    
  8. Ensure your activity is defined as public:

    public class SplashActivity extends Activity
    
  9. This may not make any difference, but remove temporarily your activity's theme tag "android:theme="@style/Theme.AppCompat.Splash", just to ensure is not a style related issue which produces an invalid manifest.

  10. Make a backup before proceeding with this solution. Close your project and delete the project's ".gradle" folder. This one will be autogenerated again next time you open it.

  11. Create a new project and import your old project's code into it.

  12. Fully reinstall Android Studio, so uninstall and install.

Upvotes: 1

Raza
Raza

Reputation: 809

This is kind of a hack. It worked for me several times.

Step 1- Change the launch option to Nothing. enter image description here

Step 2- Run the app. It will launch the app but no activity will be displayed.

Step 3- Clean the project, uninstall from the device(optional), and again change the configuration to Default Activity. And invalidate Cache and Restart.

Upvotes: 1

Ch. Vishal Ratnam
Ch. Vishal Ratnam

Reputation: 11

Try adding <category android:name="android.intent.category.DEFAULT"/> to the first <intent-filter> tag

Upvotes: 0

Related Questions