有没有人成功创建了一个他们愿意分享的card.io包装器,可以在Mono for
Android应用程序中使用,或者有人可以解释我做错了什么?
>创建一个新的Android Java Bindings Library项目
>从card.io SDK 3.0.3添加.jar和.so文件,请务必使用现有的文件夹结构
>将以下内容添加到Transforms / EnumMethods.xml以解决编译器错误:
<mapping jni-class="io/card/payment/CardioActivity"> <method jni-name="onActivityResult" parameter="p1" clr-enum-type="Android.App.Result" /> </mapping>
>在我的主应用程序中添加对上述库的引用
一切都编译,我可以访问card.io类:
using IO.Card.Payment; private void WireupScanCardButton() { Log.Debug(this.GetType().Name,"WireupScanCardButton"); this.ScanCardButton.Click += delegate { Log.Debug(this.GetType().Name,"ScanCard.Click"); var intent = new Intent(this,typeof(CardioActivity)); // required for authentication with card.io intent.PutExtra(CardioActivity.ExtraAppToken,"<MY PRIVATE TOKEN HERE>"); // Customize these values to suit your needs. intent.PutExtra(CardioActivity.ExtraNoCamera,false); intent.PutExtra(CardioActivity.ExtraSuppressManualEntry,true); intent.PutExtra(CardioActivity.ExtraRequireExpiry,false); intent.PutExtra(CardioActivity.ExtraRequireCvv,false); intent.PutExtra(CardioActivity.ExtraRequireZip,false); // Run the Activity this.StartActivityForResult(intent,0); }; }
但是,我总是会出现以下错误:
此设备无法使用相机读取卡号
笔记:
>我尝试在几种不同的物理设备上运行
> card.io.jar文件的Build Action为:EmbeddedJar
> .so文件的Build Action为:EmbeddedNativeLibrary
>我已经为Project ItemGroup中的每个.so文件显式设置了Abi
我是Android / Xamarin的新手,所以花更多的时间研究而不是编码.
编辑:
.so文件确实被编译器拾取.
编译后,如果我检查obj / Release /文件夹,则根据支持的Abi类型,有一个子文件夹native_library_imports,其中包含相应子文件夹中的.so文件.
logcat输出:
04-18 08:12:20.462 D/ActivityAddPaymentSource( 5824): ScanCard.Click 04-18 08:12:20.472 E/ActivityManager( 191): exception bw.write()java.io.IOException: Transport endpoint is not connected 04-18 08:12:20.472 I/ActivityManager( 191): Starting: Intent { cmp=com.onetab.android/io.card.payment.CardioActivity (has extras) } from pid 5824 04-18 08:12:20.472 D/PowerManagerService( 191): acquireWakeLock flags=0x1 tag=ActivityManager-Launch 04-18 08:12:20.492 D/ActivityAddPaymentSource( 5824): OnPause 04-18 08:12:20.492 E/Sensors ( 191): GsSensor: line +83 ~~~handle===0~~en==1~~!n 04-18 08:12:20.502 E/Sensors ( 191): GsSensor::setDelay: line +113 ~~~handle===0~~ns==1553152~~!n 04-18 08:12:20.502 E/Sensors ( 191): GsSensor::setDelay: line +113 ~~~handle===0~~ns==-2135896001~~!n 04-18 08:12:20.542 W/card.io ( 5824): cardioScanErrorNoDeviceSupport: This device cannot use the camera to read card numbers. 04-18 08:12:20.572 E/ActivityManager( 191): exception bw.write()java.io.IOException: Transport endpoint is not connected 04-18 08:12:20.572 D/PowerManagerService( 191): acquireWakeLock flags=0x1 tag=ActivityManager-Launch 04-18 08:12:20.582 E/Sensors ( 191): GsSensor: line +83 ~~~handle===0~~en==0~~!n 04-18 08:12:20.622 D/ActivityAddPaymentSource( 5824): OnResume
谢谢