Android compiler: Cannot resolve symbol string

When I try to add a strServerIP to the class Server, I get a:
Cannot resolve symbol string
compiler error.

Why?

package com.example;


public class Server
{
    //public static java.lang.string SERVERIP;
    public static android.R.string SERVERIP;
    public static java.lang.string strServerIP = "monster.idsoftware.com";
    public static string strServerIP = "monster.idsoftware.com";
    public static int SERVERPORT = 27950;
    public static int PROTOCOL = 68;
}


Asked by: Rafael686 | Posted: 20-01-2022






Answer 1

Use "String" not "string"

Answered by: Freddie799 | Posted: 21-02-2022



Answer 2

In addition to RickNotFred's answer, android.R.string is not a data type, and you are using it as such in the first line of your Server implementation.

If you are new to Java, I definitely recommend spending some weeks learning Java outside of Android. Android's use of Java is just strange enough that some people seem to get frustrated learning both at the same time. Also, books on Java will not have Android in mind, and books on Android pretty much assume you already know Java.

Answered by: Melissa535 | Posted: 21-02-2022



Similar questions





Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top