BrunoVT
BrunoVT

Reputation: 723

Invalid resource directory name "font" Xamarin Android

I just upgraded Visual Studio for mac to support Android 8 / api 26. I updated the AppCompat library to 26.1 to use the new font folder in the Resources directory of my Android project. Now when I try to compile I get "Invalid resource directory name" for path "obj/Debug/res/font" APT0000.

Error message

Resources folder

Xamarin android version

Upvotes: 7

Views: 5216

Answers (4)

porya ras
porya ras

Reputation: 490

the right answer is in invalid resource directory. you must add fonts in assets/fonts and clean Rebuild

Upvotes: 0

frederickd
frederickd

Reputation: 371

My resolution for this problem was to add the following line in the root of the project file

<PropertyGroup><AndroidSdkBuildToolsVersion>27.0.3</AndroidSdkBuildToolsVersion></PropertyGroup>

Upvotes: 1

BrunoVT
BrunoVT

Reputation: 723

For me the solution was to remove all the old Android SDK Build Tools from the SDK Manager. Now I only have for api level 26 and 27 installed and it works.

enter image description here

Upvotes: 14

eugstman
eugstman

Reputation: 1048

First always check out the latest xamarin documentation about new features. https://developer.xamarin.com/guides/android/platform_features/introduction-to-oreo/

I quickly created a new xamarin android project and added two textviews with diffrent fonts:

Test App

My solution looks as the following:

Solution

I usually try to avoid capital letters in resource names as the android studio complains about it.

Main Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

  <TextView
    android:text="Pacifico example text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:fontFamily="@font/pacifico" />

  <TextView
  android:text="Roboto light example text"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:fontFamily="@font/roboto_light" />

</LinearLayout>

I think that you do not use the latest platform to build. Check that you use the latest platform (Oreo) to build the application.

Upvotes: 2

Related Questions