-6
 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"

Kasım Özdemir
  • 5,414
  • 3
  • 18
  • 35
  • This was a greatest hit recently: https://stackoverflow.com/q/17054000/2711811 –  May 10 '20 at 14:56

1 Answers1

0

Here are some techniques which you can use to remove this error:

  1. Clean your project, Buidl->clean Project

  2. Rebuild project, Build -> Rebuild Project

  3. Open manifest and check is there any resource missing

  4. Check-in layout to particular id if missing add it

  5. 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.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Pranav Choudhary
  • 2,726
  • 3
  • 18
  • 38