gpt4 book ai didi

android - card.io Mono for Android (Xamarin Studio)

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:00 26 4
gpt4 key购买 nike

有没有人成功创建了一个他们愿意分享的 card.io 包装器,可以在 Mono for Android 应用程序中使用,或者有人可以阐明我做错了什么?

  1. 创建一个新的 Android Java 绑定(bind)库 项目
  2. 添加来自 card.io SDK 3.0.3 的 .jar 和 .so 文件, 请务必使用现有的文件夹结构
  3. 将以下内容添加到 Transforms/EnumMethods.xml 以解决编译器错误:

    <mapping jni-class="io/card/payment/CardIOActivity">
    <method jni-name="onActivityResult" parameter="p1" clr-enum-type="Android.App.Result" />
    </mapping>
  4. 在我的主应用程序中添加对上述库的引用

一切都编译好了,我可以访问 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 文件中。

日志输出:

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

谢谢

最佳答案

Android logcat 应该会显示更具体的错误消息,但这个问题是由于缺少 native 库造成的。 (对于普通的 Android 项目,这些位于 /libs 目录中,具有特定于体系结构的子目录。)

这些是您提到的 .apk 中缺少的 .so 文件。它们包含所有图像处理逻辑,因此如果它们不存在,card.io 将无法扫描。

关于android - card.io Mono for Android (Xamarin Studio),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16027260/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com