2014-12-03 55 views
1

我試圖找到並導入makeramen的圖書館,因爲我不能copile我的項目,收到這些錯誤:如何導入庫在ADT項目爲Eclipse

錯誤消息:

Multiple annotations found at this line: 
    - error: No resource identifier found for attribute 'border_color' in package 'myapp' 
    - error: No resource identifier found for attribute 'mutate_background' in package 'myapp' 
    - error: No resource identifier found for attribute 'border_width' in package 'myapp' 
    - error: No resource identifier found for attribute 'oval' in package 'myapp' 

我的XML:

<com.makeramen.RoundedImageView xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/mapImage" 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:background="@drawable/list_map_bar" 
      android:padding="12dp" 
      android:scaleType="fitCenter" 
      android:src="@drawable/list_world" 
      app:border_color="@color/xroads_grey" 
      app:border_width="2dp" 
      app:mutate_background="true" 
      app:oval="true" /> 

我不知道如何解決這個問題,運行& copile的Android項目。 任何人都可以幫助我嗎?

非常感謝!


更新2

我收到被導入到ADT的Android項目 - Eclipse的。有缺少一些庫,並請檢查下面的完整結構的項目形象:

的Android項目(對不起,我可以上傳圖像,因爲計算器不要讓我上載的任何圖像):

LoginActivity 
    -Android 4.3 
    -Referenced Libraries 
     -rundedimageview-1.5.0-sources.jar 
    -src 
    -gen [Generated Java Files] 
    -assets 
    -bin 
    -libs 
    -res 
    -AndroidManifest.xml 
    -ic_launcher-we.png 
    -lint.xml 
    -project.properties 

下的文件夾/ res/layout在我之前提到的關於缺少庫和依賴關係的文件上有一些錯誤消息。所以我已經將RoundedImageView JAR添加到項目中,但沒有任何更改。

有什麼想法? 讓我知道是否有人需要關於任何文件的更多信息o錯誤消息。 它缺少build.gradle文件,這是正常的或我可以創建?

更新3:

我改變了代碼爲納迪姆·伊克巴勒推薦,但錯誤依然存在。我可以在代碼中運行帶有這些錯誤的應用程序。請幫忙!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res/io.cran.crossroads" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <FrameLayout 
     android:layout_width="100dp" 
     android:layout_height="100dp" 
     android:id="@+id/map" 
     android:layout_alignBottom="@+id/avatar" 
     android:layout_toRightOf="@id/imageBarLeft"> 

     <com.makeramen.RoundedImageView 
      android:id="@+id/mapImage" 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:background="@drawable/list_map_bar" 
      android:padding="12dp" 
      android:scaleType="fitCenter" 
      android:src="@drawable/list_world" 
      app:border_color="@color/xroads_grey" 
      app:border_width="2dp" 
      app:mutate_background="true" 
      app:oval="true" /> 
    </FrameLayout> 
+0

您是使用Eclipse IDE還是Android Studio? – behelit 2014-12-03 04:18:55

+0

我正在使用ADT - Eclipse。 – maceguo 2014-12-04 02:33:37

回答

0

看來,你可以找到你的圖書館這裏的源代碼: https://github.com/vinc3m1/RoundedImageView

下載它,並嘗試導入roundedImageView文件夾在Eclipse中。將此項目設置爲庫(Project> Properties> Android),然後轉到您自己的項目並添加庫(項目>屬性> Android>添加)。

+0

ADT沒有讓我從項目>屬性> Android添加庫,所以我手動添加在我的項目下Referenced庫。但沒有任何變化。 – maceguo 2014-12-04 02:55:46

1

在頂部的根視圖

xmlns:app="http://schemas.android.com/apk/res/YOUR.PACKAGE.NAME"

像這樣添加一行:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res/YOUR.PACKAGE.NAME" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

     <com.makeramen.RoundedImageView 
      android:id="@+id/mapImage" 
      android:layout_width="100dp" 
      android:layout_height="100dp" 
      android:background="@drawable/list_map_bar" 
      android:padding="12dp" 
      android:scaleType="fitCenter" 
      android:src="@drawable/list_world" 
      app:border_color="@color/xroads_grey" 
      app:border_width="2dp" 
      app:mutate_background="true" 
      app:oval="true" /> 

</RelativeLayout> 
+0

我改變了,但錯誤仍然存​​在。任何想法? – maceguo 2014-12-05 13:53:10

+0

@maceguo更新問題,以便我可以看到 – 2014-12-05 13:56:28

0

你缺少ATTRS值。這些應該已經存在於圖書館項目中。 嘗試重新從頭開始導入庫。

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <declare-styleable name="RoundedImageView"> 
    <attr name="corner_radius" format="dimension" /> 
    <attr name="border_width" format="dimension" /> 
    <attr name="border_color" format="color" /> 
    <attr name="mutate_background" format="boolean" /> 
    <attr name="oval" format="boolean" /> 
    <attr name="android:scaleType" /> 
    </declare-styleable> 
</resources> 

以防萬一

0

你得到這些錯誤,因爲XML命名空間的問題。在你的XML, xmlns:app="http://schemas.android.com/apk/res-auto"應改爲

xmlns:app="http://schemas.android.com/apk/lib/com.makeramen.roundedimageview"

注意 -

/RES更改爲/ lib目錄

另外,更改包名稱com.makeramen.RoundedImageView

com.makeramen.roundedimageview.RoundedImageView

試試這個:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/lib/com.makeramen.roundedimageview" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="${relativePackage}.${activityClass}" > 

<com.makeramen.roundedimageview.RoundedImageView 
    android:id="@+id/avatar" 
    android:layout_width="55dip" 
    android:layout_height="55dp" 
    android:layout_centerInParent="true" 
    android:scaleType="centerCrop" 
    android:src="@drawable/daimajia" 
    app:border_color="#ffffff" 
    app:border_width="1dp" 
    app:corner_radius="10dip" 
    app:mutate_background="true" 
    app:oval="true" /> 

</RelativeLayout> 

希望這將解決您的問題。