APK errors

Activity class does not exist

Error text

Error type 3
Error: Activity class {com.example.app/com.example.app.MainActivity} does not exist.
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] }

Cause

The screen class to start cannot be found in the APK. The manifest name is wrong, there is no LAUNCHER filter, or R8 removed the class.

Step-by-step fix

  1. Read the APK's main activity with aapt2 dump badging app.apk | grep launchable.
  2. Check that the manifest has an <activity> with MAIN and LAUNCHER intent filters.
  3. Do the full name and package match? applicationId and namespace can differ.
  4. If R8 renamed the activity in release, add a -keep rule for special cases.
  5. Start it by hand with adb shell am start -n package/.Activity.

Example commands

adb shell pm resolve-activity --brief com.example.app
adb shell am start -n com.example.app/.MainActivity
aapt2 dump badging app.apk | grep launchable

How to prevent it

When you rename the launcher activity, update the manifest at once.

Author and license: Nibras Code