我使用下面的代码片段使用从http://components.xamarin.com/gettingstarted/zxing.net.mobile下载的Zxing条形码库来读取条形码。应用程序minVersion选择为2.3,目标版本选择为自动。我在nexus 4(Android 4.4.2)上运行应用程序
BarcodeButton.Click += async delegate
{
var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
var result = await scanner.Scan();
if (result != null)
Toast.MakeText(this,"DONE",ToastLength.Short).Show();
};
当我运行应用程序时,在按下条形码按钮后,将获得此错误日志。错误是什么?我该如何解决? :
...
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> mscorlib[0x777e2a10]: 9
[Mono] Assembly Ref addref TeleLib[0x784b8c58] -> zxing.monoandroid[0x784ba440]: 2
[Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
[Mono] Unloading image mscorlib.dll [0x78801068].
[Mono] Assembly Ref addref zxing.monoandroid[0x784ba440] -> mscorlib[0x777e2a10]: 10
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> Mono.Android[0x784bbb98]: 4
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> zxing.monoandroid[0x784ba440]: 3
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> Xamarin.Android.Support.v4[0x784b9848]: 2
[Mono] Assembly Ref addref zxing.monoandroid[0x784ba440] -> Mono.Android[0x784bbb98]: 5
[] TypeRef ResolutionScope not yet handled (14) for .CameraInfo in image /data/data/TeleLib.TeleLib/files/.__override__/ZXing.Net.Mobile.dll
[Mono] The class CameraInfo could not be loaded, used in
[MonoDroid] UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'CameraInfo'.
[MonoDroid] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (intptr,intptr,intptr) <0x0005f>
[MonoDroid] at (wrapper dynamic-method) object.c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr) <0x00043>
[mono]
[mono] Unhandled Exception:
[mono] System.TypeLoadException: Could not load type 'CameraInfo'.
[mono] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (IntPtr jnienv, IntPtr native__this, IntPtr native_holder) [0x00000] in <filename unknown>:0
[mono] at (wrapper dynamic-method) object:c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'CameraInfo'.
[mono-rt] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (IntPtr jnienv, IntPtr native__this, IntPtr native_holder) [0x00000] in <filename unknown>:0
[mono-rt] at (wrapper dynamic-method) object:c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr)
答案 0 :(得分:1)
我遇到了同样的问题并且发现ZXing.NET组件需要Android 2.3版。将您的项目更改为2.3或更高版本,此错误将消失。