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;
publ开发者_Python百科ic 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;
}
Use "String" not "string"
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.
精彩评论