0

What's my Problem : I started app development using android studio today and I can't seem to get past the first part. The content after android:text=" in content_main.xml is always in red and it is being referred to as an error, even when I'm not referring to the strings.xml.

What all did I try : I read up on previous answers and I read that there must be something wrong with my xml file, that I might have messed up something which should have been there. I tried clean/rebuild. Then I deleted this project and started a new one but the problem didn't go.

SURPRISINGLY THOUGH, removing tools.context=".MainActivity" solved it.

What I want to know : Is it ok for me to continue working without the tool.context . I mean I have no idea what it does and what exactly is causing the problem. I would love to know a proper fix.

Here I am attaching the image for my xml file. Link

1 Answers1

0

It is perfectly fine for you to continue developing without the tools:context attribute, this is only used at design time and it will ignore when you build your APK as shown in this post.


You haven't really solved the issue on the second image btw, you have a bad formed XML and your project won't compile.

Community
  • 1
  • 1
Evin1_
  • 12,292
  • 9
  • 45
  • 47
  • Try invalidating Android Studio cache. http://stackoverflow.com/a/30450020/2503185 – Evin1_ Jul 10 '16 at 23:43
  • Setting up the JDK home? http://stackoverflow.com/questions/16574189/android-studio-installation-on-windows-7-fails-no-jdk-found – Evin1_ Jul 11 '16 at 00:10
  • Ok, i tried clean once again, then did sync build with gradle. Restarted the whole thing. It still shows the string in red(and says cannot resolve symbol 'string') but is compiling the way I want it to. – Kumar Ashish Jul 11 '16 at 00:14
  • the avd shows the right output. This helped http://stackoverflow.com/questions/17054000/cannot-resolve-symbol-r-in-android-studio – Kumar Ashish Jul 11 '16 at 00:16