Is there a legal use for @ + android: id?

After I updated my Android tools to the latest version to work with API21 , trying to compile my project resulted in the following error:

  • update_languages_button_preference_layout.xml: 2: note: did you mean to use @ + id instead of @ + android: id ?
  • update_languages_button_preference_layout.xml: 2: error: creating resource for external package android: id / layout.
  • update_languages_button_preference_layout.xml: 2: error: Error: The resource was not found that matches the specified name (in 'id' with value '@ + android: id / layout' ).

The problem seems to lie in the line android:id="@+android:id/layout"

: replacing @ + android: id with @ + id was enough to get the project to compile and run normally.

However, a quick search throughout the codebase revealed several other places in the project where the construct was used android:id="@+android:id/...

. Apparently this did not stop the project from passing all tests, even if I cannot guarantee that they are still in use.

  • Is there a legitimate use android:id="@+android:id

    that would justify leaving these links in our xml files and not replacing them all with @+id

    ?

  • Why didn't they raise the same error as the first file?

+3


source to share


2 answers


No, you should never use @ + android: id in your application. The android namespace is reserved for the framework. This application was never application safe and now generates a compile error.

For a little background, creating new ids in the android namespace puts them in an unused space after the existing android namespace ids. This will work fine until new IDs are added to the structure, at which point your internal ID will overlap with the actual frame ID and cause weird problems.



As with other cases, they should also generate errors. There may be a bug in the AAPT. Regardless, you must remove all @ + android instances from your resources.

+3


source


Although my comment is very late. I faced the same issue today when I was updating my eclipse and instruments. Changed @ + android: id to @ + id and it solved my problem.



+3


source







All Articles