使用 Android O 的 XML 字体 [英] Font in XML with Android O
问题描述
Android O 使用新的 android-studio 3.0 版提供字体目录,但是当在字体目录中放置字体文件并运行项目时,它在字体目录中的字体文件中给我一个错误.错误:任务:app:mergeDebugResources"的执行失败.
<块引用>/home/ttuser4/Downloads/fontPractice/app/src/main/res/font/Dancing_Script.ttf:错误:文件名必须以.xml结尾
我也遇到了类似的问题.为了解决这个问题,我按照以下步骤操作.
- 将 Android Studio 更新为最新的 Canary 版本.
- 将
project-dir/gradle/gradle-wrapper.properties
中的distributionUrl
更改为最新的 gradle 分发 url(您可以从 此处) 更新用于构建的 gradle 版本,如下所示.<块引用>distributionUrl=https://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
- 然后将根
build.gradle
中的com.android.tools.build:gradle
版本更新为最新的,如下所示.(注意:下面提到的版本是发布答案时的最新版本.版本可能会在未来发生变化.所以请注意这一点.)
<前>构建脚本{存储库{jcenter()行家{网址https://maven.google.com"}}依赖{类路径 'com.android.tools.build:gradle:3.0.0-alpha4'}}所有项目{存储库{jcenter()行家{网址https://maven.google.com"}}}任务清理(类型:删除){删除 rootProject.buildDir}
- 同步、清理和更新项目.
它对我有用.让我知道您的意见.
Android O give font directory with new android-studio version 3.0 but when in drop font-file in font directory and run project it give me a error in font file in font directory. Error:Execution failed for task ':app:mergeDebugResources'.
/home/ttuser4/Downloads/fontPractice/app/src/main/res/font/Dancing_Script.ttf: Error: The file name must end with .xml
I also got the similar issue. To fix that i followed the below steps.
- Updated Android Studio to latest canary build.
- Change
distributionUrl
inproject-dir/gradle/gradle-wrapper.properties
to latest gradle distribution url(You can get the latest availability of gradle from here) to update the gradle version used to build like below.distributionUrl=https://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
- Then update
com.android.tools.build:gradle
version in the rootbuild.gradle
to the latest like below. (Note: Below mentioned version is the latest one when the answer is posted. The version might be change in future. So take care about that.)
buildscript { repositories { jcenter() maven { url 'https://maven.google.com' } } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-alpha4' } } allprojects { repositories { jcenter() maven { url 'https://maven.google.com' } } } task clean(type: Delete) { delete rootProject.buildDir }
- Sync, Clean and update the project.
It worked for me. Let me know with your comments.
这篇关于使用 Android O 的 XML 字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!