无效的资源目录名称 "font" Xamarin Android
Invalid resource directory name "font" Xamarin Android
我刚刚将 Visual Studio 升级为 mac 以支持 Android 8 / api 26。我将 AppCompat 库更新到 26.1 以使用新的字体文件夹我的 Android 项目的资源目录。现在,当我尝试编译时,我得到 "Invalid resource directory name" for path "obj/Debug/res/font" APT0000.
首先始终查看有关新功能的最新 xamarin 文档。
https://developer.xamarin.com/guides/android/platform_features/introduction-to-oreo/
我快速创建了一个新的 xamarin android 项目并添加了两个具有不同字体的文本视图:
我的解决方案如下所示:
我通常会尽量避免在资源名称中使用大写字母,因为 android 工作室对此有所抱怨。
主要布局:
<?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>
我认为你没有使用最新的平台来构建。
检查您是否使用最新平台 (Oreo) 构建应用程序。
对我来说,解决方案是从 SDK 管理器中删除所有旧的 Android SDK 构建工具。现在我只安装了 api 级别 26 和 27 并且它有效。
我解决这个问题的方法是在项目文件的根目录中添加以下行
<PropertyGroup><AndroidSdkBuildToolsVersion>27.0.3</AndroidSdkBuildToolsVersion></PropertyGroup>
正确答案在
invalid resource directory。
您必须在 assets/fonts 中添加字体并清理 Rebuild
我刚刚将 Visual Studio 升级为 mac 以支持 Android 8 / api 26。我将 AppCompat 库更新到 26.1 以使用新的字体文件夹我的 Android 项目的资源目录。现在,当我尝试编译时,我得到 "Invalid resource directory name" for path "obj/Debug/res/font" APT0000.
首先始终查看有关新功能的最新 xamarin 文档。 https://developer.xamarin.com/guides/android/platform_features/introduction-to-oreo/
我快速创建了一个新的 xamarin android 项目并添加了两个具有不同字体的文本视图:
我的解决方案如下所示:
我通常会尽量避免在资源名称中使用大写字母,因为 android 工作室对此有所抱怨。
主要布局:
<?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>
我认为你没有使用最新的平台来构建。 检查您是否使用最新平台 (Oreo) 构建应用程序。
对我来说,解决方案是从 SDK 管理器中删除所有旧的 Android SDK 构建工具。现在我只安装了 api 级别 26 和 27 并且它有效。
我解决这个问题的方法是在项目文件的根目录中添加以下行
<PropertyGroup><AndroidSdkBuildToolsVersion>27.0.3</AndroidSdkBuildToolsVersion></PropertyGroup>
正确答案在 invalid resource directory。 您必须在 assets/fonts 中添加字体并清理 Rebuild