Xamarin.Forms.Platform.Android does not exist after Xamarin update from 2.5 to 3.5

时间秒杀一切 提交于 2021-02-04 07:32:07

问题


I have updated my projects Xamarin.Forms NuGet package from version 2.5 to 3.5. After this update I got an error in my Android project saying:

The type or namespace name 'Android' does not exist in the namespace 'Xamarin.Forms.Platform' (are you missing an assembly reference?)

What I've tried so far:

  • Delete bin, obj folders
  • Close and Reopen solution
  • Clean and Rebuild solution
  • Reinstalling Xamarin Forms NuGet

回答1:


@Jaymin is right. You must make sure that the version of the installed Xamarin.Android should be as same as the version that you have added to the current project.

For example, if you have installed v27.0.2.1 of Xamarin.Android, you can not upgrade your project to v28.0.0.1 only. You should upgrade the component(Xamarin.Android) which is installed with Visual Studio first.




回答2:


In my case, I updated the target Android version in Android Manifest.xml file. But this didn't relfect in in the .Android.csproj file.

I had to manually update the target version. Doing so, will display a prompt to reload the project. Please reload it.

Steps to edit the project file in VS for Mac.

  1. Right click on the Android project and select "Edit project File" option.
  2. Edit the <TargetFrameworkVersion>v11.0</TargetFrameworkVersion> to your target version. I have added v11.0 as the target here.
  3. Save the project and accept the reload prompt. you're good to go.

You should not be seeing the compiler error again, if the Android target version is the root cause.




回答3:


Versions were the same when the problem presented itself in my case (and the OP). After trying many things...

The solution was: Delete the Xamarin.Forms.x.x.xxxxxx (currently installed version) NuGet file folder in MySolution\Packages folder. Then, upgrade the Android Project nuget project.

I also deleted all old version folders of Xamarin.Forms from my packages folder first.




回答4:


Update the Xamarin.forms to version 4.3.0.991250 and it's compatible with Android 8.1 Compile and builds.



来源:https://stackoverflow.com/questions/54591881/xamarin-forms-platform-android-does-not-exist-after-xamarin-update-from-2-5-to-3

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