user2693709
user2693709

Reputation: 31

error: No resource identifier found for attribute in custom-views from http://developer.android.com

I'm learning to develop android applications following the tutorial in http://developer.android.com.

Now I'm working on http://developer.android.com/training/custom-views/create-view.html and when I build the application I get the errors:

D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'showText' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'labelHeight' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'labelWidth' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'labelY' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'labelPosition' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'highlightStrength' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'pieRotation' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'labelColor' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'autoCenterPointerInSlice' in package 'com.example.android.customviews.charting'
D:\sviluppo\netbeans\custom-view\res\layout\main.xml:24: error: No resource identifier found for attribute 'pointerRadius' in package 'com.example.android.customviews.charting'

I downloaded the code from the website and I installed it as it is, without any change so the main.xml is

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res/com.example.android.customviews"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
<com.example.android.customviews.charting.PieChart
        android:id="@+id/Pie"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:layout_weight="100"
        custom:showText="true"
        custom:labelHeight="20dp"
        custom:labelWidth="110dp"
        custom:labelY="85dp"
        custom:labelPosition="left"
        custom:highlightStrength="1.12"
        android:background="@android:color/white"
        custom:pieRotation="0"
        custom:labelColor="@android:color/black"
        custom:autoCenterPointerInSlice="true"
        custom:pointerRadius="4dp"
        />
<Button
        android:id="@+id/Reset"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/reset_button"
        />
</LinearLayout>

and namespaces are the same.

Can you help me to understand why I'm getting these errors? Thanks a lot.

Upvotes: 2

Views: 4630

Answers (3)

Bill
Bill

Reputation: 1268

I downloaded the same custom-demo from Android.com, and had the same problem.

Changing

xmlns:custom="http://schemas.android.com/apk/res/com.example.android.customviews"

to either

xmlns:custom="http://schemas.android.com/apk/lib/com.example.android.customviews"

or

xmlns:custom="http://schemas.android.com/apk/res-auto"

worked. There were some differences between them, and I found the second solution perfect for what I needed. I don't know why it works.

Upvotes: 1

Ravtech developer
Ravtech developer

Reputation: 219

I also had the same problem and the answer is in this link.

In short, you need to replace

http://schemas.android.com/apk/res/com.example.android.customviews

with

http://schemas.android.com/apk/lib/com.example.android.customviews

Namely, /res/ to /lib/.

Upvotes: 18

android_iphone_coder
android_iphone_coder

Reputation: 23

I meet the same problem,I think your custom attributes don't belong to the right namespace.You can get the demo of customview_panda and look at custom attribute in the main.xml,you will understand. https://github.com/pandabo1985/Android_App_Prac

Upvotes: 0

Related Questions