Search code examples
javaandroidandroid-studiocard.io

Android library card.io skipping camera and not scanning card on Moto X 2nd Gen


I'm trying to use the fantastic card.io library to scan credit cards just like Über manages to do on my Moto X 2nd Gen and the library is not working. It gives the following output on Android Monitor:

 I/card.io: card.io 5.4.2 09/27/2016 11:38:46 -0500
 E/card.io: Failed to load native library: dlopen failed: cannot locate symbol "__aeabi_memcpy" 
    referenced by "/data/app/br.com.feliperochamachado.cardscantest-2/lib/arm/libcardioDecider.so"...
 I/card.io: Processor not Supported. Skipping camera.

Since Über does work properly on this same phone, and it does use card.io, I believe it is a problem with my setup, but it is a very simple test app that only try to reproduce the barebones guidelines to get it working. Here is my gradle.build file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "br.com.feliperochamachado.cardscantest"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'io.card:android-sdk:5.4.2'
    testCompile 'junit:junit:4.12'
}

And here is my manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="br.com.feliperochamachado.cardscantest">

    <!-- Permission to vibrate - recommended, allows vibration feedback on scan -->
    <uses-permission android:name="android.permission.VIBRATE" />

    <!-- Permission to use camera - required -->
    <uses-permission android:name="android.permission.CAMERA" />

    <!-- Camera features - recommended -->
    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
    <uses-feature android:name="android.hardware.camera.flash" android:required="false" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Activities responsible for gathering payment info -->
        <activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" />
        <activity android:name="io.card.payment.DataEntryActivity" />
    </application>

</manifest>

The code that calls the scanning activity follows:

public void onScanPress(View v) {
    Intent scanIntent = new Intent(this, CardIOActivity.class);

    // customize these values to suit your needs.
    scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: false
    scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false
    scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false

    // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity.
    startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);
}

And my layout is very simple:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context="br.com.feliperochamachado.cardscantest.MainActivity">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Scan Card"
        android:onClick="onScanPress"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</LinearLayout>

Clicking on the button will write the aforementioned warnings to the Android Monitor, skip using the camera altogether, and display a data entry form instead.

I can't find what is wrong. Perhaps the library SDK is not bundling the needed libs, but I don't even know where to look to check it out!

Importing the SampleApp inside the SDK into Android Studio 2.2.2 gives the same result!


Solution

  • I've commented on two issues on the card.io github projects:

    The sample app worked fine on a Moto X 1st Gen device.

    Since ÜBER does work correctly on my device, I've tried to downgrade the library version and it did work correctly with the version 5.4.0. Just had to change my gradle dependcies to this:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:24.1.1'
        compile 'io.card:android-sdk:5.4.2'
        testCompile 'junit:junit:4.12'
    }
    

    I'll be giving this feedback on card.io's issue tracker on github.

    EDIT: It also works fine with version 5.4.1!