I know that if you write something wrong in code you get a red underline.
My problem is that the whole word turns red and I get the error
"Cannot resolve symbol '(and then whatever the code is)'"
when I hold the mouse over it.
I have downloaded Java just to see if it were the problem. I also followed this tutorial on how to download Android studio.
The program I made is from this tutorial on Youtube.
The path text in the top gets a red underline.
I don't know if it helps but i'm using Windows 10 and Android Studio 3.3
Here you can see my code turning red:
You're writing Kotlin in a Java file. Because of this, your IDE doesn't understand the symbols you're using to define variables. Note that even more recent versions of Java don't support val, which is why I presume you're attempting to use Kotlin here.
Your choice: write your code in either Kotlin or Java, but not both at the same time.
Related
I have recently set up my VS code to be able to run Java. I downloaded the extension pack for java and then downloaded Azul Zulu jdk to run java programs. So far it runs fine, but for certain snippets of code orange blocks of text will appear. They cannot be deleted or modified in any way, and I haven't changed any settings besides changing VS code to use the Zulu jdk as my default jdk.
Example of the orange blocks I'm getting
I have tried going through my setting related to Java in my VS code, but I can't find anything that would cause this. I haven't done anything besides set up my default jdk and installing the extension for java.
Any help with getting rid of these orange blocks would be appreciated.
Edit:
Java> Inlay Hints > parameter names: Enabled, was the setting that was causing it. Setting this to none fixed the issue. I was confused as the guide I was following did not mention this, nor did it show up on their visual examples when writing code, even though our methods from installing to writing java would have been the same.
I develop Java in vscode + some java extensions (one of them is Red Hat's Java support).
When I last checked in the code, I believe that Red Hat's ext attempted to format the code in some files, which made my boss furious.
If I set the java.format.enabled to off, it should not happen again, should it? I want to be able to preserve the code in whichever shape and style it was there prior to my changes.
I otherwise love working with vscode, but don't want to get into trouble.
yea, it can be.
"java.format.enabled": false,
can do it.
I installed android studio in ubuntu recently and I'm pretty new to linux. I built an app that uses a switch widget. The problem is, when I tried to access the switch object using
Switch switch = (Switch) findViewByID(R.id.switch1);
I got an error saying that it is not a valid statement along with multiple errors like '(' expected, right after the the object name, the second word in the line, 'switch'
Out of curiosity, I went to Switch.java by ctrl clicking the class name. And over there I found over 72 errors.
This is what it looks like:
I have downloaded the latest google APIs after seeing the response to this question. And I still don't know how to rectify it. I am asking this question here as a last resort. It most probably will be some silly mistake on my part while configuring the install. Please help me!
switch is a Java language keyword so you can't use it as a variable name.
I've encountered a weird glitch in Android Studio:
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)
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:
try this
httpReqquest.addHeader("Accept-Language","en-US");
Since Android Studio is a bit raw, you can face the "glitches" in many different ways. They're annoying but don't affect the result, as you said. However, I personally don't think that we should endure the inconveniences (even if the Studio costs nothing).
I see a couple of solutions:
Continue with AS and ignore these weird things, hoping they will release a robust software once
Or, to migrate to IntelliJ IDEA as I did. The procedure is pricey but it's worth it.
I am a beginner in Android programming. I was going through the official tutorial on Android developer site. When I copied the codes for the Grid View tutorial to Eclipse, many red wave underlines appeared which are not allowing me to compile. Every time I click the run button, it says "Your project contains error(s), please fix them before running your application."
I am using a WIN7 and followed every single step that is necessary for setting up the envrionment. I had no problem at with previous tutorials such as Hello Android, Linear Layout, Relative Layout, and Table View.
Does anyone have the same experience and have a solution for this? I have tried to clean and re-build the project, which doesn't help.
It would probably be helpful to provide a link to the gridview tutorial you speak of. I'll assume you meant this one: http://developer.android.com/resources/tutorials/views/hello-gridview.html
First things first: Did you download the sample art? Did you put it in res/drawable?
What errors were you getting?
Are you certain you are working in an Android project and not a standard Java project?