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'
}