[英]Xamarin Android Deployment Error
I have an app that works well on my Android 7.0 physical device and also works fine with the emulator that works on Android 6.0 API 23. I wanted to test my app if it works on Android 5.1 API 22 (Nexus 4).我有一个在我的 Android 7.0 物理设备上运行良好的应用程序,也可以在 Android 6.0 API 23 上运行的模拟器上运行良好。我想测试我的应用程序是否在 Android 5.1 API 22 (Nexus 4) 上运行。 Well, it doesn't and it gives this error:
好吧,它没有,它给出了这个错误:
The Android Manifest looks like this: Android 清单如下所示:
The Android Options page looks like this: Android 选项页面如下所示:
The advanced options for the Android options page looks like this: Android 选项页面的高级选项如下所示:
The Application options:应用程序选项:
**Note: I have tried using the Supported Architecture menu in the advanced tab and have tried only selecting "x86_64" and it did not solve the error for me. **注意:我曾尝试使用高级选项卡中的支持架构菜单,并尝试只选择“x86_64”,但它并没有为我解决错误。
I got this from the output of Xamarin Diagnostics:我从 Xamarin Diagnostics 的输出中得到了这个:
[I:]: Found Xamarin.Android 7.3.1.2
[I:sdk]: Runtime path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community New\MSBuild\Xamarin\Android
[I:sdk]: Framework path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community New\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0
[I:sdk]: Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_f80dbffe\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_f80dbffe\Android\AndroidNdkDirectory found:
Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b).
[I:sdk]: Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_f80dbffe\Android\JavaSdkDirectory found:
Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.8.0_131).
[I:]: Found Android SDK. API levels: 22, 23, 24, 25
[I:]: Tracking android devices started
[D:]: TrackDeviceTask got: 710f5e7a device
[I:]: Got new device list from adb with 1 devices
[D:RunShellCommand]: 710f5e7a getprop
[D:RunShellCommand]: 710f5e7a getprop
[D:]: Tracking avd started
[D:]: avd watcher *.ini path: 'C:\Users\cx67\.android\avd'
[D:]: avd watcher: got device list from avd with 5 devices
[D:]: avd watcher: got device list from avd with 5 devices
[D:]: TrackDeviceTask got: emulator-5554 offline, 710f5e7a device
[I:]: Got new device list from adb with 2 devices
[D:]: TrackDeviceTask got: emulator-5554 device, 710f5e7a device
[I:]: Got new device list from adb with 2 devices
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 date +%s
[D:RunShellCommand]: emulator-5554 setprop "debug.mono.extra" "debug=127.0.0.1:29274:29275,timeout=1499696237,loglevel=0,server=y"
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 "echo" "-n" "${EMULATED_STORAGE_SOURCE}"
[D:RunShellCommand]: emulator-5554 "echo" "-n" "${EMULATED_STORAGE_TARGET}"
[D:RunShellCommand]: emulator-5554 am broadcast -a "mono.android.intent.action.EXTERNAL_STORAGE_DIRECTORY" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.ExternalStorageDirectory"
[D:RunShellCommand]: emulator-5554 "echo" "-n" "${EXTERNAL_STORAGE}"
[D:RunShellCommand]: emulator-5554 am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "LoginSystem.Android/md50ef850b548eeb6d8287c9a52e2084363.SplashActivity"
[D:RunShellCommand]: emulator-5554 ps
[D:GetLogCat]: logcat -v time
[D:RunShellCommand]: emulator-5554 logcat -v time
[D:RunShellCommand]: emulator-5554 am force-stop LoginSystem.Android
[D:RunShellCommand]: emulator-5554 setprop "debug.mono.connect" ""
[D:]: avd watcher: got device list from avd with 5 devices
[D:]: TrackDeviceTask got: 710f5e7a device
[I:]: Got new device list from adb with 1 devices
[D:]: avd watcher: got device list from avd with 5 devices
[D:]: avd watcher: got device list from avd with 5 devices
[D:]: TrackDeviceTask got: emulator-5554 offline, 710f5e7a device
[I:]: Got new device list from adb with 2 devices
[D:]: TrackDeviceTask got: emulator-5554 device, 710f5e7a device
[I:]: Got new device list from adb with 2 devices
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: 710f5e7a date +%s
[D:RunShellCommand]: 710f5e7a setprop "debug.mono.extra" "debug=127.0.0.1:29276:29277,timeout=1499697764,loglevel=0,server=y"
[D:RunShellCommand]: 710f5e7a getprop
[D:RunShellCommand]: 710f5e7a "echo" "-n" "${EMULATED_STORAGE_SOURCE}"
[D:RunShellCommand]: 710f5e7a "echo" "-n" "${EMULATED_STORAGE_TARGET}"
[D:RunShellCommand]: 710f5e7a am broadcast -a "mono.android.intent.action.EXTERNAL_STORAGE_DIRECTORY" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.ExternalStorageDirectory"
[D:RunShellCommand]: 710f5e7a am start -a "android.intent.action.MAIN" -c "android.intent.category.LAUNCHER" -n "LoginSystem.Android/md50ef850b548eeb6d8287c9a52e2084363.SplashActivity"
[D:RunShellCommand]: 710f5e7a ps
[D:GetLogCat]: logcat -v time
[D:RunShellCommand]: 710f5e7a logcat -v time
[D:RunShellCommand]: 710f5e7a am force-stop LoginSystem.Android
[D:RunShellCommand]: 710f5e7a setprop "debug.mono.connect" ""
[I:]: Found Android SDK. API levels: 22, 23, 24, 25
[D:RunShellCommand]: emulator-5554 getprop
[D:RunShellCommand]: emulator-5554 am broadcast -a "mono.android.intent.action.PACKAGE_VERSIONS" -e "packages" "Mono.Android.DebugRuntime,Mono.Android.Platform.ApiLevel_22,LoginSystem.Android" -n "Mono.Android.DebugRuntime/com.xamarin.mono.android.PackageVersions"
[D:RunShellCommand]: emulator-5554 pm install "/data/local/tmp/LoginSystem.Android-Signed.apk"
[D:RunShellCommand]: emulator-5554 rm "/data/local/tmp/LoginSystem.Android-Signed.apk"
[E:]: Deployment failed
Mono.AndroidTools.InstallFailedException: Unexpected install output: pkg: /data/local/tmp/LoginSystem.Android-Signed.apk
Failure [0]
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in C:\d\lanes\4699\fec6f88f\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\external\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 325
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass91_0.<InstallPackage>b__0(Task`1 t) in C:\d\lanes\4699\fec6f88f\source\xamarinvs\External\md-addins\MonoDevelop.MonoDroid\external\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 740
at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Running the app in release mode gives this error:在发布模式下运行应用程序会出现此错误:
Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Void Android.App.Activity::OnRequestPermissionsResult(System.Int32,System.String[],Android.Content.PM.Permission[])' (defined in assembly 'Xamarin.Android.Support.Fragment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.App.Activity::OnRequestPermissionsResult(System.Int32,System.String[],Android.Content.PM.Permission[])
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() LoginSystem.Android
Setting the Target Android Version to 6.0 has solved this error.将目标 Android 版本设置为 6.0 已解决此错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.