簡體   English   中英

錯誤“找不到屬性'rectLayout'的資源標識符”

[英]Error “No resource identifier found for attribute 'rectLayout'”

我試圖在eclipse中為android佩戴創建一個新項目,但是在主要布局中有一個問題我現在不知道如何解決它,這是我的主要布局:

<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="match_parent"
    android:layout_height="match_parent"
    app:rectLayout="@layout/rect"
    app:roundLayout="@layout/round"
    tools:context=".MyActivity"
    tools:deviceIds="wear">
</android.support.wearable.view.WatchViewStub>

它給我這個錯誤:

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

我的項目有兩個布局“rect.xml”和“round.xml”,它是用4.4W編譯的,目標是4.4W,我在libs文件夾中有一個classes.jar的副本。

您發布的代碼很好。 這里的問題是你的/libs文件夾中有一個classes.jar的副本,但這不是正確使用wearable-support-lib的正確方法。 這個wearable-support-lib包含一些無法打包在.jar文件中的資源,所以你需要將它作為“ 庫項目 ”導入,並像其他外部庫一樣將它附加到你的項目中。

您需要返回與您的sdk文件夾相關的wearable-1.0.0.aar文件:
./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

  1. 將整個wearable-1.0.0.aar文件解壓縮到您的工作區。 你會發現它看起來幾乎像一個標准的android項目。
  2. classes.jar移動到/libs/classes.jar - 在此項目內,而不是您自己的項目。
  3. 現在你必須從這些文件創建新項目,包名稱定義為android.support.wearable
  4. 使用API​​ 20編譯它,並在Android選項卡中的項目屬性中選中“Is Library”。
  5. 從項目中添加對此庫項目的引用。

您可以在我的其他答案本篇博文 (BenjaminCabé)中看到有關使用wearable-support-lib的更多詳細信息。

我剛剛在模塊的build.gradle中的依賴項部分添加了以下代碼: build.gradle : build.gradle : build.gradle compile 'com.google.android.support:wearable:2.0.3' compile 'com.google.android.gms:play-services-wearable:11.0.0'

我有時也遇到這個問題,在我的情況下,我通過右鍵單擊AppCompat地圖然后點擊刷新來解決它,也可以使用你的項目文件夾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM