Invalid resource directory name “font” Xamarin Android

匿名 (未验证) 提交于 2019-12-03 01:23:02

问题:

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.

回答1:

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:

My solution looks as the following:

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.



回答2:

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.



回答3:

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> 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!