I got the solution for this.
If you want to write native code or edit existing native code you have to open the “android” part of your project specifically.
You can do that be going to : File -> Open …..
Then browse to your current project and select its “android” folder and open it :
Then click “OK”.
It will open the android native part of your project. All the errors will be gone if you will open the MainActivity through this path.