2014-09-30 70 views
3

我正在嘗試爲eclipse中的android磨損創建一個新項目,但主佈局中存在一個問題我現在不怎麼解決這個問題,這是我主要佈局:錯誤「找不到屬性'rectLayout'的資源標識符'

<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的副本。

+0

我不認爲有一個名爲rectLayout爲'http://schemas.android.com/apk屬性/ res-auto' – zgc7009 2014-09-30 21:03:31

回答

5

您發佈的代碼很好。這裏的問題是您的/libs文件夾中有classes.jar副本,但這不是正確使用穿戴支持庫文件的正確方法。這穿戴支持庫包含一些無法打包在.jar文件中的資源,因此您需要將其導入爲「庫項目」,並將其作爲其他外部庫附加到您的項目。

你需要回到wearable-1.0.0.aar文件,位於相對於您的SDK文件夾:
./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

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

你可以看到有關我的other answerthis great blog post使用可佩戴支持-lib的(本傑明CABE)的更多細節。

+0

謝謝,它正在工作:) – 2014-09-30 23:22:19

0

我也有時會遇到這個問題,在我的情況下,我通過在AppCompat地圖上點擊右鍵,然後點擊刷新來解決它,然後使用您的項目文件夾執行此操作。

1

我只是說在依賴部分下面的代碼在我的模塊build.gradlecompile 'com.google.android.support:wearable:2.0.3' compile 'com.google.android.gms:play-services-wearable:11.0.0'

相關問題