Android Studio installs the app but cannot start the activity
Run installs the APK, then fails when Android Studio tries to start the activityShort answer
The APK installed, but the activity named in the launch request is not in it. Android Studio takes that name from the run configuration's Launch Options, so a renamed or moved class leaves it pointing at nothing. Fix the Launch option, or make the activity name in the manifest resolve to a real class.
Fix it fast
1Find out which cause you have
Open the run configuration and read the Launch Options. Then compare the activity named there with the activity element in the manifest.
grep -n -B1 -A6 "<activity" app/src/main/AndroidManifest.xml2Match what you see, then jump to its fix
- 1
Launch is set to Specified Activity and the Activity field holds an old class name, often after a rename or a package move.The run configuration launches a Specified Activity that no longer existsFix - 2
The manifest says android:name=".MainActivity" but the class lives in another package than the namespace in build.gradle.A dot-prefixed activity name no longer matches the namespaceFix
- 1
What does the error look like?
Run installs the APK, then fails when Android Studio tries to start the activityThe Run window shows an error that the activity class does not exist
Cause 1 of 2
The run configuration launches a Specified Activity that no longer exists
1Check
Run > Edit Configurations > your app > General tab > Launch Options. Android Studio offers Nothing, Default Activity, Specified Activity and URL.
grep -rn "class .*Activity" app/src/main2Fix
Switch Launch to Default Activity, which starts the activity marked MAIN and LAUNCHER in the manifest. Or pick the current class from the Specified Activity list.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>3Verify
Press Run again; the activity starts.
./gradlew :app:installDebugConfirmed by developer.android.com
Cause 2 of 2
A dot-prefixed activity name no longer matches the namespace
1Check
A name that starts with a period is appended to the namespace from the module build file. Compare the two values.
grep -n "namespace" app/build.gradle*
grep -rn "class MainActivity" app/src/main2Fix
Make the namespace match the package that holds the activity, or write the activity's full class name in the manifest.
<activity android:name="com.example.myapp.ui.MainActivity"
android:exported="true" />3Verify
Rebuild and run; the merged manifest should name a class that exists.
./gradlew :app:assembleDebugConfirmed by developer.android.com
How do I stop it coming back?
- Use Default Activity in the run configuration unless you truly need another start screen.
- Rename classes with the IDE's Refactor > Rename so the manifest is updated with them.
- Keep namespace equal to the package that holds your activities, as Android's guide recommends.
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