开发者

Android: R-class Syntax error on tokens

I'm new to android programming and I've got a problem, when I change the main.xml file I get error in the R.java class on all the other classes, like +id, attr, drawable. The error says:

Syntax error on tokens, delete these tokens

Why am I getting this? I use the latest JDK,开发者_高级运维 latest SDK, Win 7, Eclipse, Android 2.3.3

Thanks for all help.

This is the main.xml code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView  
        android:id="@+id/tasks_title"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/tasks"
        />


     <TextView  
        android:id="@++id/task_title_text"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/tasks_title"
        android:layout_above="@+id/add_button"

        />

     <Button  
        android:id="@id/add_button"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/add_task"     
        android:layout_alignParentBottom="true"
        />


</RelativeLayout>


The second TextView got two + on its id. Remove one and you should be fine.

You may have to clean your project to rebuild the automatically generated ressources. To do so, select "Project->Clean" from eclipse.

This error may be confusing sometimes when you get lots of errors indicating all your drawables, ids and such are broken. The reason is simple: Once the creation of one ressource fails, the whole ressource generation is cancelled. So look at the ressources you edited recently and check their syntax. Usually the error will be there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜