我的R.java文件中的错误无法解决

时间:2022-07-13 20:52:10

I am using the Eclipse ADT bundle and recently updated my Android SDK tools and Android SDK platform tools then thereafter I tried creating a new project and I keep getting an error in my R.java file that seems trivial but I still dont understand how it keeps showing up since it is an autogenerated file.
The error is:
Syntax error, insert "}" to complete ClassBody.

Keep in mind this is when I have just created the project. Also deleting the file and letting it autogenerate still yields the same result that is the error.
Please help on how I can solve this,can't seem to find any links to a newer ADT bundle.
This error shows up in the console:

ERROR: In MenuView, unable to find attribute android:preserveIconSpacing

我正在使用Eclipse ADT软件包,最近更新了我的Android SDK工具和Android SDK平台工具,然后我尝试创建一个新项目,并且我的R.java文件中的错误似乎微不足道但我仍然不明白它是如何保持的出现,因为它是一个自动生成的文件。错误是:语法错误,插入“}”以完成ClassBody。请记住,这是我刚刚创建项目的时候。删除文件并让它自动生成仍会产生与错误相同的结果。请帮助我如何解决这个问题,似乎无法找到任何新的ADT包的链接。此错误显示在控制台中:错误:在MenuView中,无法找到属性android:preserveIconSpacing

4 个解决方案

#1


8  

  1. Navigate to \Android.Support.v7.AppCompat\2x.x.x\content\support\v7\appcompat\res\values\attrs.xml in side your project directory.

    导航到项目目录旁边的\ Android.Support.v7.AppCompat \ 2x.x.x \ content \ support \ v7 \ appcompat \ res \ values \ attrs.xml。

    or

    要么

    open the AppCompat project in your workspace and navigate to \res\values\attrs.xml

    在工作区中打开AppCompat项目并导航到\ res \ values \ attrs.xml

  2. Find "android:preserveIconSpacing" in attrs.xml file and and comment that line.

    在attrs.xml文件中找到“android:preserveIconSpacing”并注释该行。

  3. Rebuild the project again.

    再次重建项目。

Hope this solves the issue.

希望这能解决问题。

#2


0  

i did comment "android:preserveIconSpacing" but generate more error. i have back up appcompat_v7 and replace it with broken one and every thing goes right again .

我做了评论“android:preserveIconSpacing”,但产生了更多的错误。我已备份appcompat_v7并将其替换为损坏的,并且每件事情都会再次正确。

#3


0  

This problem occurs when you update the ADT. So it is recommendable to use Android Studio.
If that doesnt work then try what @Harsh Dattani stated in the previous answer which is to Clean or Rebuild the project.

更新ADT时会发生此问题。所以建议使用Android Studio。如果那不起作用,那么试试@Harsh Dattani在上一个回答中说清楚或重建项目的内容。

#4


0  

i think it's SDK Manager-Tools not installed.

我认为它没有安装SDK Manager-Tools。

#1


8  

  1. Navigate to \Android.Support.v7.AppCompat\2x.x.x\content\support\v7\appcompat\res\values\attrs.xml in side your project directory.

    导航到项目目录旁边的\ Android.Support.v7.AppCompat \ 2x.x.x \ content \ support \ v7 \ appcompat \ res \ values \ attrs.xml。

    or

    要么

    open the AppCompat project in your workspace and navigate to \res\values\attrs.xml

    在工作区中打开AppCompat项目并导航到\ res \ values \ attrs.xml

  2. Find "android:preserveIconSpacing" in attrs.xml file and and comment that line.

    在attrs.xml文件中找到“android:preserveIconSpacing”并注释该行。

  3. Rebuild the project again.

    再次重建项目。

Hope this solves the issue.

希望这能解决问题。

#2


0  

i did comment "android:preserveIconSpacing" but generate more error. i have back up appcompat_v7 and replace it with broken one and every thing goes right again .

我做了评论“android:preserveIconSpacing”,但产生了更多的错误。我已备份appcompat_v7并将其替换为损坏的,并且每件事情都会再次正确。

#3


0  

This problem occurs when you update the ADT. So it is recommendable to use Android Studio.
If that doesnt work then try what @Harsh Dattani stated in the previous answer which is to Clean or Rebuild the project.

更新ADT时会发生此问题。所以建议使用Android Studio。如果那不起作用,那么试试@Harsh Dattani在上一个回答中说清楚或重建项目的内容。

#4


0  

i think it's SDK Manager-Tools not installed.

我认为它没有安装SDK Manager-Tools。