button = (Button) findViewById(R.id.button);
maintext = (TextView) findViewById(R.id.maintext);
setContentView(R.layout.activity_main);
there are three different reasons for explanations of "package R does not exist"
button = (Button) findViewById(R.id.button);
maintext = (TextView) findViewById(R.id.maintext);
setContentView(R.layout.activity_main);
there are three different reasons for explanations of "package R does not exist"
Here are some techniques which you can use to remove this error:
Clean your project, Buidl->clean Project
Rebuild project, Build -> Rebuild Project
Open manifest and check is there any resource missing
Check-in layout to particular id if missing add it
If the above steps did not work then restart android studio with invalidating the cache
Also, ensure that your android_library/android_binary is using an AndroidManifest.xml with the correct package= attribute, and if you're using the custom_package attribute on android_library or android_binary, ensure that it is spelt out correctly.
Also, make sure you have added correct package name on top of your java class.