LoginSignup
0
0

More than 5 years have passed since last update.

Xamarin.AndroidでAmbiguity between ...の警告が出るようになった

Last updated at Posted at 2018-06-22

少し前にVisualStudioを7.5にアップデートしてから、Xamarin.AndroidプロジェクトのResource.Idでリソースを参照する箇所全てで以下の警告が出るようになりました。

Ambiguity between 'Resource.Id.xxx' and 'Resource.Id.xxx'

ビルドエラーになるわけでは無いので放っておいたのですが、結構目立つので解決策を調べてみました。

起きている現象

スクリーンショット 2018-06-22 18.05.35.jpg

こんな感じで、Resource.Id.xxxの箇所全てに波線が引かれています。
ビルドに問題はありませんが、目障りですね。

現象が起きた環境

一部抜粋です。

=== Visual Studio Community 2017 for Mac ===

Version 7.5.1 (build 22)

=== Xamarin.Profiler ===

Version: 1.6.2

=== Xamarin.Android ===

Version: 8.3.0.19 (Visual Studio Community)

=== Xamarin Inspector ===

Version: 1.4.0

=== Operating System ===

Mac OS X 10.13.5

解決策

ちょろっと調べたらすぐ出てきました。

Updating to Visual Studio Community 7.5 causes ambiguous resource layouts #1670

上記のうち、ちょうど現時点(2018/06/22)の前日に投稿されたコメント(なんてタイムリー!)のやり方が私の環境では効きました。

その方法は、

対象となるプロジェクトのcsprojファイルの各PropertyGroup
内に

<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>

を追加してビルドするだけです。

こんな感じです。

<PropertyGroup
    <AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

...

</PropertyGroup>

上記の後にビルドしたところ、先ほどまでの波線がスッキリ消えました

スクリーンショット 2018-06-22 18.27.33.jpg

これで快適に開発が続けられそうです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0