Android Studio error: Invalid character: & amp; #39; \ ufeff & amp; #39; and Gradle cannot automatically search for xml Custom Attributes

Source: Internet
Author: User

Android Studio error: Invalid character: & #39; \ ufeff & #39; and Gradle cannot automatically search for xml Custom Attributes

 

1. invalid characters :'? '

When importing a project to Studio, the system prompts an error: Invalid character :'? ', The compiler does not report errors but compilation errors, more headaches, and later found that the reason is because the use of UTF-8 without BOM mode, with Notepad ++ or other editor to open the file, change the format can be solved:

 

Note: Eclipse can intelligently convert a BOM file to a non-BOM file. Currently, Andorid Studio has not processed the file. The following is a simple description of BOM (Byte-Order Mark), which can be understoodByte sequence markIs the name of the unified character located at the Code Point U + FEFF. This character is used to indicate its byte order when it is encoded as a string consisting of a UTF-16 or a UTF-32. It is often used as a sign that the file is coded in UTF-8, UTF-16, or UTF-32. The common point is the byte sequence mark, and the transfer mark is enough. More information to learn about the official website: http://www.unicode.org/faq/utf_bom.html#BOM

 

 

Ii. Gradle cannot automatically find xml Custom Attributes

In the layout xml file, Gradle cannot automatically search for custom properties:

In Gradle projects, always use http://schemas.android.com/apk/res-auto for custom attributes

 

 

Modify the custom property http://schemas.android.com/apk/res/com.xxx.xxx to: http://schemas.android.com/apk/res-auto. For example:

 

 

 

3. the following error solution appears in Studio:

Error: duplicate files during packaging of APK ........
Path in archive: META-INF/LICENSE.txt

Exclude 'meta-INF/NOTICE.txt'

You can ignore those files in your build. gradle:
Android {
PackagingOptions {
Exclude 'meta-INF/LICENSE.txt'
}
}
Error: Execution failed for task': app: packagedebug '.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1:/StudioProject/app/libs/xxx. jar
File 2:/StudioProject/app/libs/xxx. jar

 

Because multiple jars contain the same file (notice.txt), an error is prompted due to mutual coverage concerns during packaging.
Try to add a configuration for android in build. gradle of the app:
PackagingOptions {
Exclude 'meta-INF/LICENSE.txt'
Exclude 'meta-INF/NOTICE.txt'
}

 

 

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.