Xamarin Forms 生成错误的资源 [英] Xamarin Forms generates wrong ressources

查看:14
本文介绍了Xamarin Forms 生成错误的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 Xamarin Forms 的 Xamarin Android 应用程序.从 Xamarin Forms 3.4.0.1029999 更新后,我的 Resource.Designer 中有如下条目:

//aapt 资源值:0x7F030220公共常量 int bottomtab.navarea = 2130903584;//aapt 资源值:0x7F030221public const int bottomtab.tabbar = 2130903585;

有了这些,我得到了很多这样的错误:

我认为这是因为重点.有趣的是,构建仍然成功.我该如何解决这个错误?

项目链接:https://github.com/MoneyFox/MoneyFox

解决方案

这似乎是最近引入的一个错误,对 BottomTabLayout.axml 文件进行了更改,最终导致生成的设计文件使用 . 字符而不是 _ 字符.更多详细信息:https://github.com/xamarin/xamarin-android/issues/3007#issuecomment-486622711

Xamarin 工程师已经意识到这个问题,并有一个修复程序应该很快发布,但与此同时,你可以通过回退到旧的 aapt 生成器来解决这个问题,如下所示这些步骤:

  1. 右键单击 Android 项目并选择 Unload Project.如果项目从 IDE 中消失,请确保解决方案显示所有文件,而不仅仅是项目中的文件.
  2. 右键单击卸载的 Android 项目并选择Edit Project 以打开 .csproj 文件.
  3. 在第一个 PropertyGroup 标记中,添加以下内容:

错误的</AndroidUseManagedDesignTimeResourceGenerator>

  1. 保存更改,然后右键单击 Android 项目并选择Reload Project.

如果一切顺利,错误现在应该会自行纠正.您可能需要清理和构建,但根据我的经验,一旦重新加载 Android 项目,就会立即进行更正.请注意,根据错误报告,aapt 生成器会变慢,如果对 axml 文件进行更改并且 Design Time Build 正在运行,这一点可能会很明显.>

I have a Xamarin Android application with Xamarin Forms. After the update from Xamarin Forms 3.4.0.1029999 I have entries in my Resource.Designer like this:

        // aapt resource value: 0x7F030220
        public const int bottomtab.navarea = 2130903584;

        // aapt resource value: 0x7F030221
        public const int bottomtab.tabbar = 2130903585;

With these I get a lot of errors like this:

I assume that this is because of the point. Funny enough the build is successful nonethless. How can I solve this errors?

Edit: the Link to the project: https://github.com/MoneyFox/MoneyFox

解决方案

This appears to be a bug that was introduced recently with a change to the BottomTabLayout.axml file, ultimately causing the generated design file to use . characters instead of _ characters. More details here: https://github.com/xamarin/xamarin-android/issues/3007#issuecomment-486622711

The Xamarin engineers are aware of the problem and have a fix lined up that should be released soon, but in the meantime, you can fix this problem by falling back to the old aapt generator by following these steps:

  1. Right-click on the Android project and select Unload Project. If the project disappears from the IDE, make sure that the solution is showing all files and not just files in the project.
  2. Right-click on the unloaded Android project and select Edit Project to open the .csproj file.
  3. In the first PropertyGroup tag, add in the following:

<AndroidUseManagedDesignTimeResourceGenerator>
    False
</AndroidUseManagedDesignTimeResourceGenerator>

  1. Save the changes, then right-click on the Android project and select Reload Project.

If all goes well, the errors should correct themselves now. You may have to clean and build, but in my experience, the correction was immediate once the Android project was reloaded. Note that according to the bug report, the aapt generator will be slower, which might be noticeable if changes are made to axml files and the Design Time Build is running.

这篇关于Xamarin Forms 生成错误的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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