Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

ActivityNotFoundException: unable to find explicit activity class at runtime

Errorandroid.content.ActivityNotFoundException: Unable to find explicit activity class

Short answer

Android starts only activities that are declared in the manifest. The error means the merged manifest of the running build has no activity with the class name you used in the intent. Check the merged manifest first. Then look for a missing declaration, a name or namespace mismatch, and a merge rule that removed it.

  • Applies to Android 10 to 16, Android Gradle Plugin 8.x, Kotlin and Java
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Search the manifest merger report of the variant you run (or the Merged Manifest tab). The activity named in the error must appear in it.

    grep -n "SettingsActivity" app/build/outputs/logs/manifest-merger-debug-report.txt
  2. 2Match what you see, then jump to its fix

    1. 1Your class is missing from the output of the command aboveThe activity is not declaredFix
    2. 2The activity is in the manifest, but under another package or spellingThe declared name does not match the classFix
    3. 3The activity is declared in one manifest, but the merged manifest of the variant you run lacks itA merge rule or build variant removes the declarationFix

What does the error look like?

  • android.content.ActivityNotFoundException: Unable to find explicit activity class
  • Have you declared this activity in your AndroidManifest.xml

Cause 1 of 3

The activity is not declared

1Check

Activities that are not declared in the manifest file are not seen by the system and never run.

grep -rn "SettingsActivity" app/src/main/AndroidManifest.xml

2Fix

Add an activity element for the class, in the module that owns the intent.

<application ...>
    <activity android:name=".SettingsActivity" android:exported="false" />
</application>

3Verify

Rebuild, reinstall and repeat the action that started the intent.

./gradlew installDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

The declared name does not match the class

1Check

A name that starts with a period is appended to the namespace in build.gradle; any other name is taken as a full class name. A moved or renamed class breaks the link.

grep -n "namespace" app/build.gradle*
grep -n "SettingsActivity" app/src/main/AndroidManifest.xml

2Fix

Make the manifest name equal the real package and class, or use the dot form under the correct namespace.

<activity android:name="com.example.app.ui.SettingsActivity" android:exported="false" />

3Verify

Build and open the screen from the app.

./gradlew installDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

A merge rule or build variant removes the declaration

1Check

The merger combines the variant, build type, flavor, main and library manifests by priority. A tools:node="remove" marker in a higher-priority file removes an element that a lower-priority file declared.

grep -rn "tools:node" app/src library/src --include=AndroidManifest.xml

2Fix

Remove the marker, or declare the activity in a manifest of higher priority than the one that removes it.

<!-- app/src/main/AndroidManifest.xml: delete this -->
<activity android:name="com.example.lib.SettingsActivity" tools:node="remove" />

3Verify

Rebuild and read the merger report again. The activity is listed.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Declare an activity in the manifest in the same commit that creates the class.
  • Use the full class name for activities in other modules.
  • Open the Merged Manifest tab when you add a library or a build variant.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.