简体   繁体   English

Xamarin Studio中内置的Xamarin Android项目在VS2015中构建,但部署失败

[英]Xamarin Android Project Built in Xamarin Studio Builds in VS2015 But Deployment Fails

I keep having an issue over and over. 我不断有一个问题。 If I create a project in Xamarin Studio, build it and run it, all works fine. 如果我在Xamarin Studio中创建一个项目,然后构建并运行它,那么一切正常。

Then I open same project in VS2015, I can build it and no errors show. 然后,我在VS2015中打开相同的项目,可以构建它并且没有错误显示。 However, if I try to run it (or deploy it) to a device or emulator, it fails. 但是,如果我尝试将其运行(或部署)到设备或仿真器,它将失败。

This is the information Visual Studio 2015 shows in Output window 这是Visual Studio 2015在“输出”窗口中显示的信息

1>No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2046-09-30) or after any future revocation date.
1>C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.0\zipalign.exe 4 "C:\Users\me\Desktop\work\xamarin\LocationTrackingService\LocationTrackingService\bin\Debug\com.user.learning.locationtrackingservice-Signed-Unaligned.apk" "bin\Debug\\com.user.learning.locationtrackingservice-Signed.apk" 
1>C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s ENU7N16723000122 devices 
1>C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s ENU7N16723000122 shell getprop ro.build.version.sdk 
1>C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s ENU7N16723000122 shell getprop ro.product.cpu.abilist64 
1>C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s ENU7N16723000122 shell pm dump com.user.learning.locationtrackingservice 
1>The "InstallPackageAssemblies" task failed unexpectedly.
1>System.AggregateException: One or more errors occurred. ---> Xamarin.AndroidTools.AndroidDeploymentException: InternalError ---> Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.usere.learning.locationtrackingservice signatures do not match the previously installed version; ignoring!]
1>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
1>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass91_0.<InstallPackage>b__0(Task`1 t)
1>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
1>   at System.Threading.Tasks.Task.Execute()
1>   --- End of inner exception stack trace ---
1>   at Xamarin.AndroidTools.AndroidDeploySession.<RunLoggedAsync>d__99.MoveNext()
1>--- End of stack trace from previous location where exception was thrown ---
1>   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
1>   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>   at Xamarin.AndroidTools.AndroidDeploySession.<StartAsync>d__98.MoveNext()
1>   --- End of inner exception stack trace ---
1>   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
1>   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
1>   at System.Threading.Tasks.Task.Wait()
1>   at Xamarin.Android.Tasks.InstallPackageAssemblies.Execute()
1>   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>---> (Inner Exception #0) Xamarin.AndroidTools.AndroidDeploymentException: InternalError ---> Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.user.learning.locationtrackingservice signatures do not match the previously installed version; ignoring!]
1>   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
1>   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass91_0.<InstallPackage>b__0(Task`1 t)
1>   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
1>   at System.Threading.Tasks.Task.Execute()
1>   --- End of inner exception stack trace ---
1>   at Xamarin.AndroidTools.AndroidDeploySession.<RunLoggedAsync>d__99.MoveNext()
1>--- End of stack trace from previous location where exception was thrown ---
1>   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
1>   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>   at Xamarin.AndroidTools.AndroidDeploySession.<StartAsync>d__98.MoveNext()<---
1>
1>Build FAILED.
1>
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

I dont know why is this happening and how to resolve the issue. 我不知道为什么会这样以及如何解决问题。 My understanding is that a project created in Xamarin Studio can be opened and run in Visual Studio and vice versa. 我的理解是,可以在Visual Studio中打开并运行在Xamarin Studio中创建的项目,反之亦然。

I think I found what the issue was. 我想我找到了问题所在。 Running adb devices listed my device and number of emulators none of which I was running ... strange. 运行adb设备列出了我的设备和仿真器的数量,但我都没有运行过...很奇怪。

Issuing 发行

adb kill-server
adb start-server
adb devices 

removed all the emulators and now only my device is listed as running 删除了所有模拟器,现在仅列出我的设备正在运行

Next, I issued 接下来,我发出

adb uninstall "com.usere.learning.locationtrackingservice"

This made sure that previous version of my application was for sure uninstalled and has not somehow left some uninstalled files on device. 这样可以确保我的应用程序的先前版本已确定已卸载,并且没有以某种方式在设备上留下一些已卸载的文件。

After this, I was able to deploy and run. 在此之后,我得以部署并运行。

There is another solution that worked for me, the steps are: 还有另一种对我有用的解决方案,步骤是:

  • Right Click on the Project Solution. 右键单击项目解决方案。
  • Properties 性质
  • Configurations Properties 配置属性
  • Check the Deploy Checkbox option. 选中部署复选框选项。
  • Then Clean the Project Solution and then Rebuild it 然后清理项目解决方案,然后重建它

It should fix the issue. 它应该解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM