Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnsatisfiedLinkError while building Tensorflow Lite demo source code

I am using Android Studio 3.0.3 with Gradle 3.3 and I was trying to build:

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/java/demo

But I was troubled by this issue:

java.lang.UnsatisfiedLinkError: No implementation found for long org.tensorflow.lite.NativeInterpreterWrapper.createErrorReporter(int) (tried Java_org_tensorflow_lite_NativeInterpreterWrapper_createErrorReporter and Java_org_tensorflow_lite_NativeInterpreterWrapper_createErrorReporter__I)
 at org.tensorflow.lite.NativeInterpreterWrapper.createErrorReporter(Native Method)
 at org.tensorflow.lite.NativeInterpreterWrapper.<init>(NativeInterpreterWrapper.java:47)
 at org.tensorflow.lite.Interpreter.<init>(Interpreter.java:77)
 at com.example.android.tflitecamerademo.ImageClassifier.<init>(ImageClassifier.java:94)
 at com.example.android.tflitecamerademo.Camera2BasicFragment.onActivityCreated(Camera2BasicFragment.java:299)
 at android.app.Fragment.performActivityCreated(Fragment.java:2620)
 at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1296)
like image 234
Jin Yifei Avatar asked Jan 12 '18 09:01

Jin Yifei


2 Answers

Following Dharma's workaround, I changed:

From:

compile 'org.tensorflow:tensorflow-lite:+'

To:

compile 'org.tensorflow:tensorflow-lite:0.1'

But the project would not build due to Gradle errors. In Android studio, I did the following:

File -> Project Settings -> Project

From:
Gradle Version: 4.4, Android Plugin Version: 3.1.0

To:
Gradle Version: 4.1, Android Plugin Version: 3.0.0

Screenshot of Android Studio Project Settings

Those settings are based on the following document that lists all the correct combinations:
Table of Plugin & Gradle Versions

With these settings, I'm able to build and run the sample projects without any problems...

like image 190
Elletlar Avatar answered Nov 02 '22 10:11

Elletlar


@Jin Yifei, I also ran into this same problem. I was able to work around it by rolling back the tensorflow-lite version to 0.1. As far as I can tell the demo doesn't seem to be compatible with 0.1.1 (which is currently the latest).

You can do so by changing app/build.gradle from :

compile 'org.tensorflow:tensorflow-lite:+'

to this :

compile 'org.tensorflow:tensorflow-lite:0.1'
like image 27
Dharma Sai Seerapu Avatar answered Nov 02 '22 10:11

Dharma Sai Seerapu