简体   繁体   中英

How can I import a library in ADT Project for Eclipse

I'm trying to find and import the library of makeramen because i can't copile my project and receive these errors:

ERROR MESSAGE:

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'

My 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" />

I dont know how to resolve this issue and run & copile the android project. Any one can help me, please?

Thanks so much!


Update 2

I received an Android project that was imported to the ADT - Eclipse. There are missing some libraries and please check the complete structure project image below:

Android Project (sorry i can upload image because stackoverflow don't let me upload any image):

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

Under the folder /res/layout there are some error message on the files that I mention before on this topic for missing the libraries and dependecies. So I had added the RoundedImageView JAR to the project but nothing change.

any ideas? let me know if someone needs more information about any file o error message. It is missing the build.gradle file, is it normal or how i can create?

UPDATE 3:

I changed the code as Nadeem Iqbal recommended but the error still there. I can run the app with these errors in the code. Please help!

<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>

Add this line in your top root view

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

Like this:

<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>

It seems that you can find the source code of your library here : https://github.com/vinc3m1/RoundedImageView

Download it and try to import the roundedImageView folder in Eclipse. Set this project as a library (Project > Properties > Android) and then, go to your own project and add the library (Project > Properties > Android > Add).

You are missing the attrs values. these should already be present in the library project. try re-importing the library from the scratch.

 <?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>

just in case

You are getting these errors because of XML namespace problem. In your xml, xmlns:app="http://schemas.android.com/apk/res-auto" should be changed to

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

Note-

/res is changed to /lib

Also, change the package name com.makeramen.RoundedImageView to

com.makeramen.roundedimageview.RoundedImageView

Try this:

<?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>

Hope this will resolve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM