本文介绍了安卓:R.java:错误<标识符GT;预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个初学者到Android的开发,并在之后的developer.android.com培训指南(更好的教程将大大AP preciated以及)。我加入行动起来吧,当我开始收到此错误。

I am a beginner to android development, and was following the training guide at developer.android.com (Better tutorials would be greatly appreciated as well). I was adding the action bar when I started getting this error.

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportSupportV132000Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42000Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable5077Library UP-TO-DATE
:app:prepareComGoogleAndroidSupportWearable100Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:compileDebugJava
C:\Users\Brian\AndroidStudioProjects\MyAndroidWear\app\build\generated\source\r\debug\com\example\brian\myandroidwear\R.java:400: error: <identifier> expected
    public static final int =action_settings=0x7f050018;
                           ^
1 error

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 12.271 secs

它还说

error:  <identifier> expected

我遇到的主要问题是R.java是由机器人工作室产生的,我从来没有碰过它让我很困惑。

The main problem I am having is that R.java is generated by android studio and I have never touched it so I am very confused.

实际R.java code是在这里。

The actual R.java code is here.

 public static final class id {
    public static final int =action_settings=0x7f050018;
    public static final int action_error=0x7f05000b;
    public static final int action_search=0x7f050017;
    public static final int action_settings=0x7f050016;
    public static final int action_success=0x7f05000d;
    public static final int all=0x7f050004;
    public static final int animation=0x7f05000e;
    public static final int bottom=0x7f050003;
    public static final int button_send=0x7f050014;
    public static final int dismiss_overlay_button=0x7f050011;
    public static final int dismiss_overlay_explain=0x7f050010;
    public static final int edit_message=0x7f050013;
    public static final int error_message=0x7f05000c;
    public static final int hybrid=0x7f050009;
    public static final int left=0x7f050000;
    public static final int message=0x7f05000f;
    public static final int none=0x7f050005;
    public static final int normal=0x7f050006;
    public static final int right=0x7f050002;
    public static final int satellite=0x7f050007;
    public static final int terrain=0x7f050008;
    public static final int text=0x7f050012;
    public static final int title=0x7f050015;
    public static final int top=0x7f050001;
    public static final int watch_view_stub=0x7f05000a;
}

该错误是扔在功能于= action_settings部分的第一行。

The error is thrown on the first line of the function at the =action_settings part.

任何帮助都将大大AP preciated。此外,如果有其他任何你需要看到,请让我知道。我仍然得到使用到Android和Android的工作室,所以我现在还不能确定这里的一切是为了帮助调试。

Any help at all would be greatly appreciated. Also if there is anything else you need to see please let me know. I'm still getting used to android and android studio so I am still not sure where everything is to help debug.

推荐答案

这听起来像你不小心用 = action_setting 的ID定义在XML的菜单项。

It sounds like you have accidentally defined a menu item in your XML with an id of =action_setting.

例如:

<menu>
    <item
        android:id="@+id/=action_settings" />
</menu>

删除 = 从你的菜单XML,你应该是好去。

Remove the = from your menu XML and you should be good to go.

这篇关于安卓:R.java:错误&LT;标识符GT;预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 13:46