【问题标题】:error: No resource identifier found for attribute 'roundLayout' in package "package name"错误:在包“包名称”中找不到属性“roundLayout”的资源标识符
【发布时间】:2014-08-19 22:53:42
【问题描述】:

我对以下属性app:RectLayout和app:Roundlayout有问题,它在xml中给出错误,说有

Multiple annotations found at this line: - error: No resource identifier found for attribute 'roundLayout' in package 'com.rarster.demowearman' - error: No resource identifier found for attribute 'rectLayout' in package 'com.rarster.demowearman'',

然后在我的主要活动中也给出了一个错误,说 R 无法解析为变量,我正在关注本教程 https://medium.com/@tangtungai/how-to-develop-and-package-android-wear-app-using-eclipse-ef1b34126a5d。我检查了我的布局文件夹中是否有圆形布局和矩形布局。谁能告诉我发生了什么以及如何解决它?提前致谢

错误所在的代码是

    <?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.WatchViewStub 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/watch_view_stub"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:rectLayout="@layout/rect"
    app:roundLayout="@layout/round"
    tools:context="com.rarster.demowearman.MainActivity"
    tools:deviceIds="wear" >

</android.support.wearable.view.WatchViewStub>

【问题讨论】:

    标签: android eclipse wear-os


    【解决方案1】:
    1. 所有 xml 属性都以小写字母开头。
    2. app:rectLayoutapp:roundLayout 都不应该放在清单中!它们必须在布局文件中使用 - 在 WatchViewStub 父视图中。

    这样:

    <android.support.wearable.view.WatchViewStub
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/stub"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        app:rectLayout="@layout/rect"
        app:roundLayout="@layout/round"
        />
    

    您的R cannot be resolved to a variable 错误是错误资源文件的影响 - 它们无法成功编译。所以请解决上面的问题,一切都会好的。

    【讨论】:

    • 实际上是我的错,我在 watchview 存根中确实有它而不是清单,对此感到抱歉,我将它作为 app:rectLayout 和 app:roundLayout 它仍然无法正常工作。
    • "它在 xml 中给出错误" - 如果您不发布错误消息,没有人将能够猜出您的代码中有什么问题...请始终发布错误消息并发布包含错误的代码。
    • 对不起,我是七年级学生,我并不总是注意,我修好了,我也放了代码
    • 你还没有发布错误信息...如果你没有写,谁知道你有什么错误?:\
    • 它在标题中,它在文本中,但我想我会更清楚......
    猜你喜欢
    • 2015-04-11
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多