Troubleshoot Android Studio under element Layer-list must be declared issues

Source: Internet
Author: User


Recently transferred a project from Eclipse to Android Studio.

The project uses some XML resources in the ring-letter demo, and after the conversion, it is found that the label of the color resource directory such as layer-list or shape, element XXX must be declared error, The main idea is that layer-list or shape these tags are undefined.


These tags, such as layer-list or shape, are frequently used tags, and Android studio reports undefined errors, which are not the problem in eclipse. Many people on the web say that this is a bug in Android studio, which is the opposite, and this is the advantage of Android Studio.


The first thing you need to know about this problem is what these tags are, such as layer-list, shape, and so on.

Each label has a corresponding resource class, and layer-list, shape, and so on are the actual drawable resources that the tag represents. Layer-list finally resolves to layerdrawable,shape will resolve to shapedrawable. Other tags are similar.

It can be seen that layer-list or shape and other resources are drawable resources, should be placed in the Drawable resource directory. The color resource does not contain a drawable resource and, of course, does not define a label for the drawable type.


Unlike Android Studio, Eclipse does not have a strict check on resource types, so there is no reporting error. I think this is the advantage of Android Studio, is what resources should be put to where, not easy to people create doubts. So the solution under Android Studio is to move these resource files to the drawable resource directory. Solve this problem.

Troubleshoot Android Studio under element Layer-list must be declared issues

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.