我刚刚在VS2017(15.3)中安装了Xamarin。
关注https://developer.xamarin.com/guides/android/platform_features/introduction_to_kitkat/和https://developer.xamarin.com/guides/android/getting_started/hello,android/hello,android_quickstart/
项目文件的应用程序android编译版本设置为 Android 4.4(Kit Kat)。
Android清单min和目标版本都设置为Android 4.4 (API Level 19 - Kit Kat)
对于调试器,我选择了
5" KitKat (4.4) XXHDPI Phone (Android 4.4 - API 19).
(7"平板电脑也不起作用)。
当我构建/重建时,我得到:
1>------ Rebuild All started: Project: Phoneword, Configuration: Debug Any CPU ------
1> Processing: obj\Debug\res\layout\main.xml
1> Processing: obj\Debug\res\values\strings.xml
1> Phoneword -> E:\Source\Workspaces\Phoneword\Phoneword\bin\Debug\Phoneword.dll
1> Processing: obj\Debug\res\layout\main.xml
1> Processing: obj\Debug\res\values\strings.xml
1> Processing: obj\Debug\res\layout\main.xml
1> Processing: obj\Debug\res\values\strings.xml
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
当我尝试调试时,我得到:"存在部署错误。继续"
1> ------ Build build:Project:Phoneword,Configuration:Debug Any CPU ------
1> Phoneword -> E:\Source\Workspaces\Phoneword\Phoneword\bin\Debug\Phoneword.dll
2>Starting deploy 5" KitKat (4.4) XXHDPI Phone ...
2>Starting emulator 5" KitKat (4.4) XXHDPI Phone ...
2>An error occured. See full exception on logs for more details.
2>Object reference not set to an instance of an object.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
错误列表:
IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.
在日志中(帮助> Xamarin>打开日志),我看到:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.VisualStudio.Shell.ThreadHelper.get_JoinableTaskContext()
at Microsoft.VisualStudio.Emulator.Utilities.VsTelemetryHelper.LogEvent(IServiceProvider serviceProvider, String eventPath, IDictionary`2 properties)
at Microsoft.VisualStudio.Emulator.Logging.VsEmulatorTelemetryLogger.LogEvent(String eventName, IDictionary`2 properties)
at Microsoft.VisualStudio.Emulator.Logging.DeviceTelemetryLogger.LogEvent(String eventName, IDictionary`2 properties)
at Microsoft.VisualStudio.Emulator.EmulatorService.<>c__DisplayClass3_0.<StartAsync>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.VisualStudio.Android.Devices.MicrosoftAndroidDeviceProvider.<>c__DisplayClass18_0.<<StartEmulator>b__0>d.MoveNext() in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio.Android\Devices\MicrosoftAndroidDeviceProvider.cs:line 114
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)
at Merq.AsyncManager.Run[T](Func`1 asyncMethod) in C:\projects\merq\src\Async\Merq.Async.Core\Merq.Async.Core.Portable\AsyncManager.cs:line 64
at Xamarin.VisualStudio.Android.Devices.MicrosoftAndroidDeviceProvider.StartEmulator(IAndroidVirtualDevice virtualDevice, IProgressReport progress, CancellationToken cancellationToken) in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio.Android\Devices\MicrosoftAndroidDeviceProvider.cs:line 114
at Xamarin.VisualStudio.Android.CommandHandlers.StartupVirtualDeviceCommandHandler.StartUp(IMonoAndroidDevice device, IProgressReport progress, IAndroidVirtualDeviceProvider virtualDeviceProvider, CancellationToken cancellationToken) in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio.Android\CommandHandlers\StartupVirtualDeviceCommandHandler.cs:line 75
at Xamarin.VisualStudio.Android.CommandHandlers.StartupVirtualDeviceCommandHandler.Execute(StartupVirtualDeviceCommand command, IProgressReport progress, CancellationToken cancellationToken) in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio.Android\CommandHandlers\StartupVirtualDeviceCommandHandler.cs:line 48
at Xamarin.VisualStudio.Commands.CommandHandlerBase`2.Execute(TCommand command, CancellationToken cancellationToken) in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio\Commands\CommandHandlerBase.cs:line 151
at Xamarin.VisualStudio.Commands.CommandHandlerBase`2.<>c__DisplayClass1_0.<ExecuteAsync>b__0() in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio\Commands\CommandHandlerBase.cs:line 117
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.VisualStudio.Android.CommandHandlers.DeployCommandHandler.<>c__DisplayClass19_0.<<StartUpVirtualDeviceAndDeploy>b__0>d.MoveNext() in C:\d\lanes\4985\306f76ac\source\xamarinvs\src\Core\VisualStudio.Android\CommandHandlers\DeployCommandHandler.cs:line 240
打开Main.axml时我得到了:
mono.android.DesignerException: java.lang.IllegalStateException
at mono.android.DesignerException.fromThrowable(DesignerException.java:46)
at mono.android.DesignerSession.checkRenderResultForError(DesignerSession.java:187)
at mono.android.DesignerSession.load(DesignerSession.java:239)
at mono.android.DesignerSession.processMessage(DesignerSession.java:704)
at mono.android.MessageListener.executeMessage(MessageListener.java:88)
at mono.android.MessageListener$Runner.run(MessageListener.java:44)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: The main Looper has already been prepared.
at android.os.Looper.prepareMainLooper(Looper.java:104)
at com.android.layoutlib.bridge.Bridge.prepareThread(Bridge.java:544)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at mono.android.DesignerSession.load(DesignerSession.java:233)
... 4 more
有什么建议吗? Android SDK Manager我安装了Android SDK Build-tools 19.1和Android 4.4.2(API 19)。
(19.1因为19.0.3 / 19.0.2 / 19.0.1 / 19已经过时)。
有关如何使其正常工作的任何建议?
(需要在三星SM-T560上用android 4.4.4编写应用程序)
答案 0 :(得分:0)
想想我修复它 - 启动适用于Android的&#34; Visual Studio模拟器&#34;从开始菜单/应用程序列表中手动启动,然后在VS仿真器工具中手动启动之后,启动它并启动它并初始化它。下次我尝试从VS内部工作正常。您也可以使用模拟器UI下载其他配置文件和API级别,然后这些将在VS2017“开始/调试”下拉列表中显示为选项。