-1

On my Android Studio, it says it "cannot resolve R symbol." So I tried rebuilding it and cleaning it several times, but it's still like this.

What do I do?

Here's my code- The first url shows my code

enter image description here

My gradle says these two things are the problem, but I don't understand it. Here's what my gradle says:

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
appmaker
  • 7
  • 4

3 Answers3

0

This happens quite often to me too. I usually end up going File> Invalidate Caches and Restart which fixes it 99% of the time

aliaksei
  • 714
  • 1
  • 9
  • 23
0

In your activity_horizontal_margin you are probably referencing a string from values.xml which doesn't exist, make sure use @+id/.... when this is a new value not declared in values.xml and are instructing the parser (or call it the builder) to create a new entry in R.java, thus you have to include a + sign.,use @id/... when you want to reference an already existing resource in values.xml so parser links this to the already created id in R.java. you can now rebuild your project.

Frank Odoom
  • 1,545
  • 18
  • 19
0

1) Please check buildToolsVersion or downgrade it. 2) make sure your appcompat compile library is included in build.gradle 3) Try to restart Android studio with invalid caches and restart 4) clean/rebuild project and then synch it.

Hope it helps

Pratik
  • 456
  • 4
  • 18