Maaz Zindani

Loading the index…

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

Android Studio installs the app but cannot start the activity

ErrorRun installs the APK, then fails when Android Studio tries to start the activity

Short 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.

  • Applies to Android Studio current stable, 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

    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.xml
  2. 2Match what you see, then jump to its fix

    1. 1Launch 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. 2The 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

What does the error look like?

  • Run installs the APK, then fails when Android Studio tries to start the activity
  • The 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/main

2Fix

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:installDebug

Confirmed by developer.android.com

Did this fix it?

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/main

2Fix

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:assembleDebug

Confirmed by developer.android.com

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

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