0

I'm using Android studio 3.4.1 on Windows 10 x64 and I'm constantly getting same error over and over. I can't run the app, because "MainActivity is not declared in AndroidManifest.json", and all code that uses something that requires permissions (NFC, read/write files, atc.) is marked as error, and the message is claiming that the permission is also missing in manifest.

These errors can be simply solved by Syncing grande files, as stated in this question: The activity 'MainActivity' is not declared in AndroidManifest.xml

However, after few minutes, these errors are back there again!

I've tried restarting the IDE many times, invalidating caches, syncing gradle many times... But nothing helps. I got these errors, I sync gradle, errors are gone, I run the app, make tiny changes in code (like changing string in setText or changing textview margin), try to run it again, and the error is back. I sync gradle again, error is solved, I run the app, then I leave the IDE, Google something, and when I return to the IDE, the error is again back, even if no changes were made to the code.

I tried to Google this issue, but I was only able to find questions where this happend once.

Obviously there something that makes the Android Studio "forget" manifest every few minutes. The issue started to occur after my computer once lost power and shut down, so my first idea was corrupted files (as it could have happend while Android Studio was saving something), but if I ran the app after grande sync, it works fine, and it lasts few minutes before the errors are there back again.

Adam Ježek
  • 464
  • 5
  • 15

1 Answers1

0

So, as this issue happening once has been asked many times about, and many times there were different replies, I just started trying other suggestions. I came acros this reply: https://stackoverflow.com/a/52687462/6357453 which suggests deleting folders with cache and other stuff Android Studio has created. I did and as of now, it's been more than an hour without this error, so this propably solved the issue.

Adam Ježek
  • 464
  • 5
  • 15
  • Hi @Adam! So, you successfully resolved this using the option "Invalidate caches and restart"? – Ashish Jul 13 '19 at 05:58
  • @Ashish no, Ivalidate caches solved the issue for few minutes. I had to delete the folders Android studio uses for caching – Adam Ježek Jul 14 '19 at 08:46