使用 Android O 的 XML 字体 [英] Font in XML with Android O

查看:25
本文介绍了使用 Android O 的 XML 字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android O 使用新的 android-studio 3.0 版提供字体目录,但是当在字体目录中放置字体文件并运行项目时,它在字体目录中的字体文件中给我一个错误.错误:任务:app:mergeDebugResources"的执行失败.

<块引用>

/home/ttuser4/Downloads/fontPractice/app/src/main/res/font/Dancing_Script.ttf:错误:文件名必须以.xml结尾

解决方案

我也遇到了类似的问题.为了解决这个问题,我按照以下步骤操作.

  1. 将 Android Studio 更新为最新的 Canary 版本.
  2. project-dir/gradle/gradle-wrapper.properties 中的 distributionUrl 更改为最新的 gradle 分发 url(您可以从 此处) 更新用于构建的 gradle 版本,如下所示.<块引用>

    distributionUrl=https://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip

  3. 然后将根 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}

  1. 同步、清理和更新项目.

它对我有用.让我知道您的意见.

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.

  1. Updated Android Studio to latest canary build.
  2. Change distributionUrl in project-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

  3. Then update com.android.tools.build:gradle version in the root build.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
}

  1. Sync, Clean and update the project.

It worked for me. Let me know with your comments.

这篇关于使用 Android O 的 XML 字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆