Andrew Fletcher published: 8 September 2023 (updated) 9 September 2023 1 minute read
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 librariesAnd the accompanying error
Unresolved class 'MainActivity'
Working through the suggestions
-
Invalidate caches
To invalidate the caches do the following
File > Invalidate caches / restartOutcome: 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 androidAdd the Android platform.
npx cap add androidNow rebuild the Android code base
npm run build && npx cap sync && npx cap copy android && npx cap open androidOr you can read more details from - Launching app code in a simulator like Xcode or Android Studio