Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsatisfied Link Error when initializing Myo hub on Android

I'm developing an Android application which will use Myo armband. I want to implement it as an accessibility service, so that gestured detected by the armband could, e.g. navigate home etc.

I'm trying to initialize the hub, but the app stops with the following error stack:

01-06 23:42:41.222 11979-11979/eu.miko.myoid E/AndroidRuntime: FATAL EXCEPTION: main
                                                           Process: eu.miko.myoid, PID: 11979
                                                           java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/eu.miko.myoid-1/base.apk"],nativeLibraryDirectories=[/data/app/eu.miko.myoid-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libgesture-classifier.so"
                                                               at java.lang.Runtime.loadLibrary(Runtime.java:367)
                                                               at java.lang.System.loadLibrary(System.java:1076)
                                                               at com.thalmic.myo.scanner.Scanner.<clinit>(Scanner.java:31)
                                                               at com.thalmic.myo.Hub.init(Hub.java:201)
                                                               at eu.miko.myoid.MyoidAccessibilityService.onCreate(MyoidAccessibilityService.java:21)
                                                               at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
                                                               at android.app.ActivityThread.-wrap4(ActivityThread.java)
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                               at android.os.Looper.loop(Looper.java:148)
                                                               at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

This is the code I use for hub initialization, as per Myo documentation. I've tried putting it in both the onCreate and onServiceConnected methods of the accessibility service, the error comes up anyhow.

    Hub hub = Hub.getInstance();
    if (hub.init(this, getPackageName())) {
        Intent intent = new Intent(this, ScanActivity.class);
        startActivity(intent);

        hub.setLockingPolicy(Hub.LockingPolicy.NONE);

        hub.addListener(mListener);
    }
    else {
        Log.e(TAG, "Could not initialize the Hub.");
    }

I'm using the most recent Myo Android SDK. Testing on Nexus 5 with most recent firmware.

To me it seems like an error inside of the SDK, but perhaps it's something to do with my configuration? Any help would be appreciated.

The samples given in the SDK don't seem to suffer from the same issue though.

In theory, the libgesture-classifier.so file is added, through the following:

  1. I'm including the Myo SDK in the project through the build.gradle file:

    dependencies {
        ...    
        repositories {
            maven {
                // this must point to the myorepository distributed with the Myo SDK
                url '../myorepository'
            }
        }
    compile('com.thalmic:myosdk:0.10.+@aar')
    }
    
  2. The myorepository contains myosdk-0.10.0.aar.

  3. Which, when I examine it as a zip, contains libs/native-libs.jar

  4. Which, in turn when examined as a zip, contains a list of architecture folders, each of which contains the single file libgesture-classifier.so

like image 220
jasiek.miko Avatar asked Jan 06 '16 23:01

jasiek.miko


1 Answers

I could resolve the issue by switching back to an earlier version of the gradle plugin for Android. There seems to be a problem with the native libraries within the myosdk, they do not get copied correctly.

Simply edit the build.gradle file from the project. Version 1.3.0 worked for me.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        **classpath 'com.android.tools.build:gradle:1.3.0'**
    }
}
like image 199
P. Brandt Avatar answered Oct 05 '22 04:10

P. Brandt