Skip to content Skip to sidebar Skip to footer

Getting Error "file Name Must End With .xml" While Using The "android:fontfamily" Of Android O?

Android O introduces a new feature, Fonts in XML, which lets you use fonts as resources. And I am creating the font folder in resource file as it provided by Android developer, but

Solution 1:

Font resources are not fully supported by the Android Studio 2.3.3 build chain. Full support comes with Android Studio 3.0+ and its associated Android Plugin for Gradle version. At that point, you will be able to create a font/ resource directory that goes alongside layout/, menu/, etc.

IOW, hold off on this until you are ready to upgrade to Android Studio 3.0.

Solution 2:

I've lost an hour on this error, using AS 3.0 beta2, Gradle 4.x and the correct build-tools.

Turned out I had a copy of the fonts in a folder called "fonts". This folder doesn't show up in the Android project view. And reading the error I didn't catch the 's'. Just a small reminder for you readers!

Solution 3:

I just had the same problem and while searching for an answer, I came here on this thread. I've found a solution from deverloper.android.com.

  1. Right click 'res' folder in Android Studio

  2. Choose 'new' > 'Android resource directory'

  3. Name it 'font'

  4. Inhere you should place your font (.ttf) files WITH ONLY a-z 0-9 and _ characters.

  5. Set your font (mine is called 'alegreyaregular.ttf') this way:

Typefacetypeface= ResourcesCompat.getFont(this, R.font.alegreyaregular);
TextView textView.setTypeface(typeface);

Solution 4:

I had exactly same error file name must end with .xml I used these settings and problem magically resolved.

Use these setting in Project Level Gradle :

compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
    applicationId "com.company.app"
    minSdkVersion 21
    targetSdkVersion 26
...
}

Use these setting in Application Level Gradle :

classpath 'com.android.tools.build:gradle:3.0.1'

Android Stidio :

Android studio version 3.0.1.

Cheers!

Solution 5:

I had faced same problem!! Just update your build.gradle file to resolve above issue.

classpath 'com.android.tools.build:gradle:3.0.1'

compileSdkVersion 26

buildToolsVersion '26.0.3'

Update your AndroidStudio to latest vetsion.

Enjoy your day.

Post a Comment for "Getting Error "file Name Must End With .xml" While Using The "android:fontfamily" Of Android O?"