有没有人成功地创建了一个card.io的包装器,并愿意分享,可以在Mono for Android应用程序中使用,或者有人能够解释一下我做错了什么?
- Create a new Android Java Bindings Library Project
- Add the .jar and .so files from card.io SDK 3.0.3, be sure to use the existing folder structure
Add the following to Transforms/EnumMethods.xml to resolve a compiler error:
<mapping jni-class="io/card/payment/CardIOActivity"> <method jni-name="onActivityResult" parameter="p1" clr-enum-type="Android.App.Result" /> </mapping>
- Add a reference to the above Library in my main application
一切都编译成功了,并且我可以访问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文件的构建操作为:EmbeddedJar
- .so文件的构建操作为:EmbeddedNativeLibrary
- 我已经在项目ItemGroup中明确设置了每个.so文件的Abi
我非常新于Android/Xamarin,所以花费更多时间研究而不是编码。
.so文件似乎没有出现在.apk文件中
编辑:
编译后,.so文件似乎被编译器捕获。 如果我检查obj/Release/文件夹,会发现一个子文件夹native_library_imports,其中包含根据支持的Abi类型的适当子文件夹中的.so文件。
然而,.so文件仍然没有出现在最终的.apk文件中。
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
谢谢