ActivityNotFoundException: unable to find explicit activity class at runtime
android.content.ActivityNotFoundException: Unable to find explicit activity classShort 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.
Fix it fast
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.txt2Match what you see, then jump to its fix
- 1
Your class is missing from the output of the command aboveThe activity is not declaredFix - 2
The activity is in the manifest, but under another package or spellingThe declared name does not match the classFix - 3
The 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
- 1
What does the error look like?
android.content.ActivityNotFoundException: Unable to find explicit activity classHave 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.xml2Fix
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 installDebugConfirmed by developer.android.com
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.xml2Fix
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 installDebugConfirmed by developer.android.com
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.xml2Fix
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 assembleDebugConfirmed by developer.android.com
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:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fixMobile apps
Android Studio says it could not identify the launch activity when you press Run
Run > Edit Configurations > Launch Options is set to Nothing or to a class that no longer exists
Android Studio launches the activity marked with a MAIN action and a LAUNCHER category in the merged manifest.
3 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fixMobile apps
Java and Kotlin compile to different JVM targets in an Android module
Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (1.8) and 'kaptGenerateStubsDebugKotlin' (17)
Java and Kotlin tasks in the same module are compiling for different JVM targets, for example 1.8 and 17.
2 causes, each with a fixMobile apps
Manifest.permission.POST_NOTIFICATIONS shows red or does not resolve
Cannot resolve symbol 'POST_NOTIFICATIONS'
POST_NOTIFICATIONS exists only from API level 33.
4 causes, each with a fix