cannot find symbol variable

I was working on my app and everything was normal until I tried to display image in java.

I ran the app once and it ran normally, the picture was displayed. After that it asked me to import some libraries and I imported them. After that I got errors for my activities.

In MainActivity I have imported these libraries:

and in secondActivity these:

Does anyone know how to fix this?

EDIT: I deleted import android.R; and now it works normally.

8 Answers 8

You shouldn’t be importing android.R . That should be automatically generated and recognized. This question contains a lot of helpful tips if you get some error referring to R after removing the import.

Some basic steps after removing the import, if those errors appear:

  • Clean your build, then rebuild
  • Make sure there are no errors or typos in your XML files
  • Make sure your resource names consist of [a-z0-9.] . Capitals or symbols are not allowed for some reason.
  • Perform a Gradle sync (via Tools > Android > Sync Project with Gradle Files)


Copy link Quote reply

chilupa commented Apr 20, 2017 •

This was the error while I’m trying to run my app. It is showing me error here.
error: cannot find symbol variable menu

Can you please help me in solving this. I’m unable to figure out.

When I performed gradlew build —stacktrace , This was the Stack trace i got.

This comment has been minimized.

Copy link Quote reply

notdrone commented Apr 21, 2017

Make sure you have this file inside your menu folder.

While compiling my code I am getting this error

error: cannot find symbol variable DrawingImageView

Can someone lead me to how to overcome this?

Premium Content
Premium Content
  • Facebook
  • Twitter
  • LinkedIn
  • copy

Thanks for both the responses.

This program had been working as is but has gone berserk now. I only changed the background to black from white in the layout and the display to full screen. Since then bringing it back to the original also does not work.

Anyhow, can you please do the change to the code. I am not sure I understand how you want me to do it. I am new to this sector.

Thanks in advance.

Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Оцените статью