Search code examples
javaandroidandroid-studiovisual-glitch

Android Studio not recognizing String


I've encountered a weird glitch in Android Studio: Android studio String glitch

As you can see it thinks that it is an error:

'class' or 'interface' expected

But it runs and build just fine, so is this just a visual glitch or can it have any effect during compiling?

I'm running Android Studio 0.5.8 for Mac

Things I've tried so far:

  • Restart Android Studio
  • Restart MacBook
  • Invalidate caches and restart
  • tried other strings (like "en-US" this result in the same effect)

If I use a string through the resources the glitch isn't visible (which it will be eventually, I'm just curious why this is happening)


Solution

  • IntelliJ and Android Studio have the ability to take string parameters and treat the strings as being in another language. For example, if you have a method that takes a string that's HTML, if you tell the IDE about it, it can give you syntax highlighting and content assist with the HTML in that string.

    I think you've inadvertently set this string as being treated as Java, and it's giving you the Java syntax errors on it. You need to un-set that setting. Select the text, bring up the Search Action feature (on Mac it's shift a). In the search box that comes up, search for Un-inject Language/Reference, as shown in the screenshot below:

    Screenshot of IDE, showing search for the command to uninject language/reference