在 VS 2017 中安装 Xamarin 并在 app.xaml.cs 中创建跨平台项目后,我有十个错误和九个警告(没有做任何事情)。我已经进行了搜索,我找到了将 xamarin 表单更新到最新版本的解决方案,但 xamarin 表单的最新版本为 2.5.0.28
我得到的错误和警告:
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?) App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 6 Active
Error CS0246 The type or namespace name 'Application' could not be found (are you missing a using directive or an assembly reference?) App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 10 Active
Error CS0115 'App.OnStart()': no suitable method found to override App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 19 Active
Error CS0115 'App.OnSleep()': no suitable method found to override App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 24 Active
Error CS0115 'App.OnResume()': no suitable method found to override App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 29 Active
Error CS0246 The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?) App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 6 Active
Error CS0103 The name 'InitializeComponent' does not exist in the current context App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 14 Active
Error CS0118 'MainPage' is a type but is used like a variable App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 16 Active
Error The type 'Application' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml 2
Error The attachable property 'Resources' was not found in type 'Application'. App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml 5
Warning No resource found that matches the given name: attr 'windowNoTitle'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 2
Warning Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 2
Warning No resource found that matches the given name: attr 'windowActionBar'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 2
Warning No resource found that matches the given name: attr 'colorPrimary'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 2
Warning No resource found that matches the given name: attr 'colorPrimaryDark'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 2
Warning No resource found that matches the given name: attr 'colorAccent'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 3
Warning No resource found that matches the given name: attr 'colorAccent'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 4
Warning No resource found that matches the given name: attr 'windowActionModeOverlay'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 4
Warning Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'. App1.Android C:\Users\vtsou_000\source\repos\App1\App1\App1.Android\Resources\values\styles.xml 4
我是 Xamarin 的新开发人员,所以我不知道该怎么做。
重新启动 VS 2017 后,旧错误消失了,但我仍然收到新错误:
[I:sdk]: Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_efe5e5bc\Android\AndroidSdkDirectory found:
Path contains adb in \platform-tools (C:\Program Files (x86)\Android\android-sdk).
[I:sdk]: Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_efe5e5bc\Android\AndroidNdkDirectory found:
Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b).
[I:sdk]: Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_efe5e5bc\Android\JavaSdkDirectory found:
Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.8.0_131).
[I:]: Found Xamarin.Android 8.2.0.15
[I:]: Found Android SDK. API levels: 25, 26
[I:]: Found Xamarin.Android 8.2.0.15
[I:sdk]: Runtime path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android
[I:sdk]: Framework path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0
[I:]: Tracking android devices started
[D:]: TrackDeviceTask got:
[I:]: Got new device list from adb with 0 devices
[D:]: live player watcher: got device list from live player with 1 devices
[D:]: Tracking avd started
[D:]: avd watcher *.ini path: 'C:\Users\vtsou_000\.android\avd'
[D:]: avd watcher: got device list from avd with 5 devices
[E:]: an error occurred loading avd `Android_Accelerated_Nougat`, the system image does not exists
[E:]: an error occurred loading avd `Android_ARM_Nougat`, the system image does not exists
[E:]: an error occurred loading avd `Nexus_5_API_24`, the system image does not exists
[E:]: an error occurred loading avd `Nexus_5_API_25`, the system image does not exists
还有一个错误:
Severity Code Description Project File Line Suppression State
Error CS0103 The name 'InitializeComponent' does not exist in the current context App1.Android, App1.iOS C:\Users\vtsou_000\source\repos\App1\App1\App1\App.xaml.cs 14 Active
经过多次尝试,我想出了如何解决我的问题:
从 bin 和 obj 中删除文件是完全没有必要的,我的问题并没有消失。
我做的第一件事是构建解决方案。
第二种是从android卸载并重新加载解决方案。在此之后,我的代码中没有错误。
此外,sdk 工具设置不正确,模拟器无法正常工作。所以你必须安装它们。另一件事是在所有 xaml 文件上共享变量。右键单击属性并将内置操作设置为内容,然后再次设置为嵌入式资源。
正如我从一开始就说了太多错误。Microsoft 开发人员必须解决这些问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句