Search code examples
androideclipseandroid-resourcesdeclare-styleable

Eclipse No Longer Recognizing Custom Attributes? (Android)


Yesterday, my project was building and running fine. Today, Eclipse decided it doesn't recognize my custom attributes anymore. I can't think of anything I changed that would cause this. I have around 2 dozen XML layouts full of custom attributes, and it doesn't reocgnize any of them. Here's one of the layouts (in res/layout):

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:aes="http://schemas.android.com/apk/res/com.aes.androidapp"
                  android:title="@string/ffour_analog_in_1">
    <com.aes.androidapp.IntPref android:title="@string/ffour_calibration_offset"
                                android:summary="@string/ffour_calibration_offset_sum"
                                android:key="ffour_ain1_calibration_offset"
                                android:defaultValue="0"
                                android:digits="-1234567890"
                                android:gravity="right"
                                android:inputType="numberSigned"
                                aes:range="-19999:30000"/>

    <com.aes.androidapp.IntPref android:title="@string/ffour_filter_time"
                                android:summary="@string/ffour_filter_time_sum"
                                android:key="ffour_ain1_filter_time"
                                android:defaultValue="0"
                                android:digits="-1234567890"
                                android:gravity="right"
                                android:inputType="numberSigned"
                                aes:range="-600:600"/>
</PreferenceScreen>

Here's my attributes file (res/values/attrs.xml):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="IntPref">
        <attr name="range" format="string" />
        <attr name="condition" format="string" />
    </declare-styleable>
</resources>

With the XML file being seen as having errors, R isn't being generated as a result IntPref.java also has issues. I've been tearing my hair out over this for the last 8 hours and can't see anything that I've done incorrect. Any suggestions?


Solution

  • It took nearly a full week to track down what the issue was, but I finally found it:

    Somehow I had inadvertently changed the package name in the Manifest.

    As a general debugging tip for everyone, I'm going to say what helped me track this down: I looked through the files that were changed in commits (the whole project is on GitHub) in/around the day this issue happened. I noticed one commit where a large portion of a manifest for a similar project was copied into this project, including the package name of the similar package. Thus how the package name had been changed in this project's manifest, and thus the issue that made it so attributes were no longer recognized. It seems like this is the kind of issue that was so improbable to occur that no one will ever have it, but just in case it does happen, that's what the answer to my problem ended up being.