【问题标题】:Eclipse Syntax Error on Token with nothing apparently wrong令牌上的 Eclipse 语法错误,没有明显错误
【发布时间】:2013-08-23 22:39:27
【问题描述】:

我一直在尝试让这段 Android 代码工作一段时间,而 eclipse 在不应该出现语法错误时给了我非常有用的语法错误。我检查了我的括号,我得到了正确的数字,我相信它们都在它们应该在的地方。这是从教程中复制和粘贴的代码,并稍作调整。提供的代码全部有效,但我的版本给出了错误。我没有改变那么多。

public class MainActivity extends Activity{

Button Pull_Data; 


// Define the TextViews

TextView client_Address1;
TextView client_Address2;
TextView client_Address3;
TextView client_Id;

// XML node keys
static final String KEY_ITEM = "Address"; // parent node
static final String KEY_PERSON = "addedByPerson";
static final String KEY_CITY = "addressCity";
static final String KEY_LINE_ONE = "addressLineOne";
static final String KEY_LINE_TWO = "addressLineTwo";
static final String KEY_STATE = "addressState";
static final String KEY_TYPE_ID = "addressTypeId";
static final String KEY_ZIP = "addressZip";
static final String KEY_CLIENT_ID = "clientId";
static final String KEY_COUNTRY_CODE = "countryCode";
static final String KEY_OBJECT_ID = "objectId";
static final String KEY_RECORD_ADDED_DATE = "recordAddedDate";
static final String KEY_RECORD_UPDATED_DATE = "recordUpdatedDate";
static final String KEY_RECORD_UPDATED_PERSON = "recordUpdatedPerson";
static final String KEY_SYNC_STATUS = "syncStatus"; //Syntax error is flagged here

// XML Data to Retrieve
Address = "";
addedByPerson = "";
addressCity = "";
addressLineOne = "";
addressLineTwo  = "";
addressState  = "";
addressTypeId  = "";
addressZip = "";
clientId = "";
countryCode = "";
objectId = "";
recordAddedDate = "";
recordUpdatedDate = "";
recordUpdatedPerson = "";
syncStatus = "";



// Holds values pulled from the XML document using XmlPullParser
String[][] xmlPullParserArray = {{"Address", "0"},{"addedByPerson", "0"},{"addressCity", "0"},{"addressLineOne", "0"},{"addressLineTwo", "0"},
    {"addressState", "0"},{"addressTypeId", "0"},{"addressZip", "0"},{"clientId", "0"},
    {"countryCode", "0"},{"objectId", "0"},{"recordAddedDate", "0"},{"recordUpdatedDate", "0"},
    {"recordUpdatedPerson", "0"},{"syncStatus", "0"}};


int parserArrayIncrement = 0;

// END OF NEW STUFF


@Override
protected void onCreate(Bundle savedInstanceState){ //Another error here, tagged at the first paren after onCreate
    super.onCreate(savedInstanceState);

我不知道可能出了什么问题。从结构上讲,代码没有改变。第一个错误由 static final String KEY_SYNC_STATUS = "syncStatus";是令牌“;”上的 Synatx 错误,{ 应在此令牌之后

OnCreate 方法的两个错误是 token "(" 预期的语法错误;和 token ")" 预期的语法错误;任何帮助表示赞赏

【问题讨论】:

  • 结束 onCreate 和 Activity 的右方括号在哪里?
  • 括号都存在且正确,我数了数并仔细检查(只是为了便于阅读,这里没有包含 300 行代码)

标签: java android eclipse


【解决方案1】:

你的错误在这里:

// XML Data to Retrieve
Address = "";
addedByPerson = "";
addressCity = "";

您缺少类型。什么是地址,一个字符串?什么是按人添加的?

// XML Data to Retrieve
String Address = "";
String addedByPerson = "";
String addressCity = "";
...

【讨论】:

  • 它们都是字符串。出于某种原因,我认为它们已经被定义了。没有帮助日食没有意识到它们是问题并指向它们上方的线。谢谢。
【解决方案2】:

这是什么?它不是 Java 类的有效部分:

//XML Data to Retrieve
Address = "";

Eclipse 有它自己的编译器,它会尝试按部分编译文件。它被称为增量编译器。 也许它只是不能将您的课程拆分为可编译的块?尝试解决这些问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-16
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多