Xamarin Android和Microsoft.Extensions.Logging

时间:2018-03-12 17:13:36

标签: android xamarin

我创建了一个"空白应用程序(Android)"来自visual studio 2017社区模板的项目。如果我添加Microsoft.Extensions.Logging版本1.1.2 nuget包并在我的Android 7.0设备上启动/调试项目,一切正常。如果我做了完全相同的事情,但添加了Microsoft.Extensions.Logging包的2.0.0版(最新稳定版),当我启动/调试应用程序时,它会立即静默地崩溃调试器。

请帮我弄清楚为什么会这样。

我的假设是当应用程序加载它试图找到缺少的引用时,但我没有办法帮助我弄清楚哪个。

更新

这是我的VS和Java信息

[I:sdk]:                    Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_d5719253\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_d5719253\Android\AndroidNdkDirectory found:
    Path contains ndk-stack in \. (C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b).
[I:sdk]:                    Key HKCU\SOFTWARE\Xamarin\VisualStudio\15.0_d5719253\Android\JavaSdkDirectory found:
    Path contains jarsigner.exe in \bin (C:\Program Files\Java\jdk1.8.0_152).
[I:]:                     Found Xamarin.Android 8.2.0.15
[I:]:                     Found Android SDK. API levels: 19, 21, 22, 23, 24, 25, 26, 27
[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: 17654e30506ed9d6 device
[I:]:                     Got new device list from adb with 1 devices
[D:RunShellCommand]:      17654e30506ed9d6 getprop
[D:RunShellCommand]:      17654e30506ed9d6 getprop
[D:]:                     live player watcher: got device list from live player with 0 devices
[D:]:                     Tracking avd started
[D:]:                     avd watcher *.ini path: 'C:\Users\xxxx\.android\avd'
[D:]:                     avd watcher: got device list from avd with 8 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

这是1.1.2的调试日志(它更长。我只附加了开头)

Android application is debugging.
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/App3.dll
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.DependencyInjection.Abstractions.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.Logging.Abstractions.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.Logging.dll [External]
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: Java.Interop.dll [External]
Loaded assembly: System.Runtime.dll [External]
Loaded assembly: System.Collections.Concurrent.dll [External]
Loaded assembly: System.Collections.dll [External]
Loaded assembly: System.Threading.dll [External]
Loaded assembly: System.Runtime.InteropServices.dll [External]
Loaded assembly: System.Reflection.dll [External]
Loaded assembly: System.Linq.dll [External]
Loaded assembly: System.Core.dll [External]
Loaded assembly: System.Runtime.Extensions.dll [External]
Loaded assembly: System.Reflection.Extensions.dll [External]
Loaded assembly: MonoDroidConstructors [External]
03-13 11:18:02.561 E/Zygote  (30809): v2
03-13 11:18:02.561 I/libpersona(30809): KNOX_SDCARD checking this for 10221
03-13 11:18:02.561 I/libpersona(30809): KNOX_SDCARD not a persona
03-13 11:18:02.563 E/Zygote  (30809): accessInfo : 0
...
...
...

这是2.0.0版本的调试日志(我已将整个内容包括在内,因为它很简短)

Android application is debugging.
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/App3.dll
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.DependencyInjection.Abstractions.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.Logging.Abstractions.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.Logging.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.Options.dll [External]
Loaded assembly: /storage/emulated/0/Android/data/App3.App3/files/.__override__/Microsoft.Extensions.Primitives.dll [External]
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: Java.Interop.dll [External]
Loaded assembly: System.Runtime.dll [External]
Loaded assembly: System.Collections.Concurrent.dll [External]
Loaded assembly: System.Collections.dll [External]
Loaded assembly: System.Threading.dll [External]
Loaded assembly: System.Runtime.InteropServices.dll [External]
Loaded assembly: System.Reflection.dll [External]
Loaded assembly: System.Linq.dll [External]
Loaded assembly: System.Core.dll [External]
Loaded assembly: System.Runtime.Extensions.dll [External]
Loaded assembly: System.Reflection.Extensions.dll [External]

这是2.0.0版本构建的警告。 1.1.2版本中没有警告。

Build succeeded.

"C:\Users\xxxx\source\repos\App3\App3.sln" (default target) (1) ->
"C:\Users\xxxx\source\repos\App3\App3\App3.csproj" (default target) (2) ->
(_ResolveAssemblies target) -> 
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1528,2): warning : Ignoring C:\Users\xxxx\.nuget\packages\system.runtime.compilerservices.unsafe\4.4.0\ref\netstandard2.0 as it is a Reference Assembly [C:\Users\xxxx\source\repos\App3\App3\App3.csproj]

    1 Warning(s)
    0 Error(s)

0 个答案:

没有答案