google-ai-edge / LiteRT

LiteRT is the new name for TensorFlow Lite (TFLite). While the name is new, it's still the same trusted, high-performance runtime for on-device AI, now with an expanded vision.
https://ai.google.dev/edge/litert
Apache License 2.0
168 stars 13 forks source link

UnsatisfiedLinkError: Failed to load native TensorFlow Lite methods #106

Open gaikwadrahul8 opened 2 days ago

gaikwadrahul8 commented 2 days ago

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.

Source code / logs

Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem.

Steps to reproduce:

  1. Create a new Android project.
  2. Add TensorFlow Lite dependencies:
    implementation("org.tensorflow:tensorflow-lite:2.14.0")
    implementation("org.tensorflow:tensorflow-lite-support:0.4.3")
  3. Download BlazeFace tflite model and add to src/main/assets folder
  4. Initialise Tensorflow Lite Interpreter in onCreate() of MainActivity:
        val model = FileUtil.loadMappedFile(this, "blaze_face_short_range.tflite")
        val options = Interpreter.Options()
        options.numThreads = 4
        val interpreter = Interpreter(model, options)
  5. Run the app on any Android Emulator using API Level between 21 and 25 included.
  6. App crashes with the following error:
    E  FATAL EXCEPTION: main
    Process: com.example.myapplication, PID: 8645
    java.lang.UnsatisfiedLinkError: Failed to load native TensorFlow Lite methods. Check that the correct native libraries are present, and, if using a custom native library, have been properly loaded via System.loadLibrary():
      java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "strtod_l" referenced by "/data/app/com.example.myapplication-2/base.apk!/lib/arm64-v8a/libtensorflowlite_jni.so"...
        at org.tensorflow.lite.TensorFlowLite.init(TensorFlowLite.java:137)
        at org.tensorflow.lite.NativeInterpreterWrapper.<init>(NativeInterpreterWrapper.java:62)
        at org.tensorflow.lite.NativeInterpreterWrapperExperimental.<init>(NativeInterpreterWrapperExperimental.java:36)
        at org.tensorflow.lite.Interpreter.<init>(Interpreter.java:232)
        at com.example.myapplication.MainActivity.onCreate(MainActivity.kt:35)
        at android.app.Activity.performCreate(Activity.java:6679)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
    Caused by: java.lang.UnsatisfiedLinkError: No implementation found for void org.tensorflow.lite.TensorFlowLite.nativeDoNothing() (tried Java_org_tensorflow_lite_TensorFlowLite_nativeDoNothing and Java_org_tensorflow_lite_TensorFlowLite_nativeDoNothing__)
        at org.tensorflow.lite.TensorFlowLite.nativeDoNothing(Native Method)
        at org.tensorflow.lite.TensorFlowLite.init(TensorFlowLite.java:132)
        at org.tensorflow.lite.NativeInterpreterWrapper.<init>(NativeInterpreterWrapper.java:62) 
        at org.tensorflow.lite.NativeInterpreterWrapperExperimental.<init>(NativeInterpreterWrapperExperimental.java:36) 
        at org.tensorflow.lite.Interpreter.<init>(Interpreter.java:232) 
        at com.example.myapplication.MainActivity.onCreate(MainActivity.kt:35) 
        at android.app.Activity.performCreate(Activity.java:6679) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6119) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
gaikwadrahul8 commented 1 day ago

This issue originally reported by @nijat-ahmadli has been moved to this dedicated repository for LiteRT to enhance issue tracking and prioritization. To ensure continuity, we have created this new issue on your behalf.

We appreciate your understanding and look forward to your continued involvement.