Skip to main content

Updating the Android app and while testing I'm seeing the following error in the AndroidManifest.xml file

Class referenced in the manifest, `com.{app_name}.app.MainActivity`, was not found in the project or the libraries

And the accompanying error

Unresolved class 'MainActivity'

 

Working through the suggestions

  1. Invalidate caches

To invalidate the caches do the following

File > Invalidate caches / restart

Outcome: error remained

 

2. Restart Android Studio

Another suggestion was to restart Android Studio.  Technically invalidating the caches incorporates a restart.  But following process, I'll test.  Expecting no change.

Outcome: error remained

 

3. Deleting the android directory

Time to delete the android directory and rebuild it.

Begin by deleting the current android directory.

rm -rf android

Add the Android platform.

npx cap add android

Now rebuild the Android code base

npm run build && npx cap sync && npx cap copy android && npx cap open android

Or you can read more details from - Launching app code in a simulator like Xcode or Android Studio

 

Related articles

Andrew Fletcher31 Oct 2023
Android icon not changing
If the Android app icon is not changing from the default icon (in my situation this was the Capacitor icon), here are some steps to troubleshoot and resolve the issue: Check the Icon FilesEnsure that you have provided the correct icon files in the appropriate directory. In a Capacitor project,...