Can not find strtod_l function on Android device
@yen-dang-ts 
In order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thank you! Hi @sushreebarsa ,

- Load model part:

```
val options = Interpreter.Options()
            val tfLite = Interpreter(
                TFLiteUtils.loadModelFile(context.assets, modelFileName),
                options
            )
```

- `loadModelFile` function
```
fun loadModelFile(assets: AssetManager, modelFilename: String?): MappedByteBuffer {
        val fileDescriptor = assets.openFd(modelFilename!!)
        val inputStream = FileInputStream(fileDescriptor.fileDescriptor)
        val fileChannel = inputStream.channel
        val startOffset = fileDescriptor.startOffset
        val declaredLength = fileDescriptor.declaredLength
        return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength)
    }
```
Pls note that this issue just happen on 2.12.0 and 2.13.0 version. Below versions still work fine.
Please have a look on that. Hi @yen-dang-ts 

What is the SDK and NDK version that are being used? 

As per the documentation,

```
NDK_API_LEVEL="26"
ANDROID_BUILD_TOOLS_VERSION="30.0.3"
ANDROID_SDK_API_LEVEL="30"
```
are recommended for the latest versions.

Thanks. Here is my config:

```
  ndkVersion "26.0.10792818"
  compileSdkVersion 33
  buildToolsVersion "30.0.3"
```
And issue still happen Hi @yen-dang-ts 

Thanks for the information. I believe there is a Android version compatibility issue with latest TF versions. 

Are you using tflite-flutter for the task?

Have you tried compiling the `libtensorflowlite_jni.so` for arm64 with the the latest TF 2.13 and nightly pull and still observe the same error?

Thanks. This problem has been reported in May for `tflite-flutter`: https://github.com/tensorflow/flutter-tflite/issues/73

The problem happens with Android 7.1.1 too. Not sure if Android 8.x/9.x are impacted (Android 13 is not impacted). (EDIT 2023-10-10: Android >= 8 are not impacted)

Where are the instructions to build `libtensorflowlite_jni.so`? I could help investigate this issue. Note that Google ML Kit Image Labeling for Flutter does support Android 5.0+ and includes runtime support for TF Lite.


 This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. > Hi @yen-dang-ts
> 
> Thanks for the information. I believe there is a Android version compatibility issue with latest TF versions.
> 
> Are you using tflite-flutter for the task?
> 
> Have you tried compiling the `libtensorflowlite_jni.so` for amr64 with the the latest TF 2.13 and nightly pull and still observe the same error?
> 
> Thanks.

@pjpratik The problem was introduced in Tensorflow Lite 2.12.0. All versions >= 2.12.0 seem to be [affected](https://github.com/tensorflow/flutter-tflite/issues/73#issuecomment-1754696187). Version 2.11.0 is not affected by this issue. I also tested version 2.10.0, not affected either.

 Hi @yen-dang-ts, @andynewman10, can you give me more context to help reproduce your issue. Do you have a toy version of your model that reproduces this issue on load? Does it run into this on any model? If you can export/share a toy project that'll be easiest, or at least tell me your imports that contextualizes your code snippets:

```
val options = Interpreter.Options()
            val tfLite = Interpreter(
                TFLiteUtils.loadModelFile(context.assets, modelFileName),
                options
            )
```
```
fun loadModelFile(assets: AssetManager, modelFilename: String?): MappedByteBuffer {
        val fileDescriptor = assets.openFd(modelFilename!!)
        val inputStream = FileInputStream(fileDescriptor.fileDescriptor)
        val fileChannel = inputStream.channel
        val startOffset = fileDescriptor.startOffset
        val declaredLength = fileDescriptor.declaredLength
        return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength)
    }
```
I should note that currently we only support NDK up to 25b and not 26, you might want to see if that resolves your issues. https://github.com/tensorflow/tensorflow/blob/1bd1b7f4b0311575ead19f14e74488a97b524555/tensorflow/lite/g3doc/android/lite_build.md?plain=1#L126
Apparently , the minimum supported version of the official build is Android 8.0 > Hi @yen-dang-ts, @andynewman10, can you give me more context to help reproduce your issue. Do you have a toy version of your model that reproduces this issue on load? Does it run into this on any model? If you can export/share a toy project that'll be easiest, or at least tell me your imports that contextualizes your code snippets:

@pkgoogle You can use any model, for instance, this one (that I confirm works flawlessly):

https://tfhub.dev/tensorflow/lite-model/efficientnet/lite4/uint8/2

Click on the Download link on the right (download size: 14.34MB), and load this model in your code.

Your code does not have to do anything meaningful. Just import the TF Lite dependencies (>= 2.12.0) in your Gradle file, and make sure that in your program, you execute the lines of code you mentionned in your post above

Then run your the code on Android 7.1.1 (real device or emulator) and this will clearly replicate the issue (libtensorflowlite_jni.so issue with 'strtod_l')

Now switch to Tensorflow Lite 2.11.0 dependencies in your Gradle file : the issue will not show up.


 > https://github.com/tensorflow/tensorflow/blob/1bd1b7f4b0311575ead19f14e74488a97b524555/tensorflow/lite/g3doc/android/lite_build.md?plain=1#L126
> 
> 
> Apparently , the minimum supported version of the official build is Android 8.0

Nice find. Apparently, this commit (dated August, 7) is the one changing API level from 21 to 26:

https://github.com/tensorflow/tensorflow/commit/6d53a5aefdecaba99e93c0933d6cc32050c108d7

As I am writing these lines, this is the latest commit affecting this file.
 @fiberflow, my bad I thought the previous comment referred to the line above that

https://github.com/tensorflow/tensorflow/blob/1bd1b7f4b0311575ead19f14e74488a97b524555/tensorflow/lite/g3doc/android/lite_build.md?plain=1#L125C1-L125C74
```
build --action_env ANDROID_NDK_HOME="/usr/local/android/android-ndk-r21e"
```
which is the NDK version not the NDK_API_LEVEL. Hi @yen-dang-ts, @andynewman10 I was able to replicate here (with SDK API level = 22, i.e. Android 5.1): [Test61951_min22.zip](https://github.com/tensorflow/tensorflow/files/12875033/Test61951_min22.zip). I was able to get around the error by using a higher SDK level, I tried with SDK API 34. If you can update your Android version and thus SDK API level you can possibly get around this.

Hi @miaout17, can you please take a look? Thanks.
 @pkgoogle Here is what I did:

- I reinstalled Android Studio Giraffe from scratch using latest version
- imported your project (Test61951_min22.zip) that has `minSdkVersion 22` specified in build.gradle, as well as `org.tensorflow:tensorflow-lite:2.13.0`
- ran the program on my Android 7.1.1 (API level 25) device

As expected, I am getting the exception:

```
Process: com.example.test61951_min22, PID: 17748
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.test61951_min22-1/lib/arm64/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)
```
After that, I switched to `org.tensorflow:tensorflow-lite:2.11.0`: the exception disappears.

**Conclusion**: Android < 8 compatibility was suddenly lost with Tensorflow Lite >= 2.12.0.

Is that expected?
 Hi @pkgoogle I have tried [Test61951_min22.zip](https://github.com/tensorflow/tensorflow/files/12875033/Test61951_min22.zip) as per your instructions and updated following versions to 34. I can confirm that I am still getting the same crash on Android Emulators using Android 7 (API level 25) and below.
```
compileSdk 34
targetSdk 34
``` > Conclusion: Android < 8 compatibility was suddenly lost with Tensorflow Lite >= 2.12.0.
> Is that expected?

The minimum API level was increased to API 26 in order to provide guaranteed support for AHardwareBuffer,
which is used by the GPU delegate for the asynchronous API.

However, I don't think the consequences of this were fully anticipated, understood, and weighed off
when that change was made.  Breaking compatibility with ~6% of existing devices (based on the numbers on https://apilevels.com/) seems undesirable.  I think TF Lite should strive to support ~99% of existing devices. @fergushenderson IMHO, it always feels really good when you know a piece of software works on a "best endeavor" basis, targeting the widest possible audience. (on a side note, I would point out the fact that Android OS versions may sometimes be upgraded for just a few years only for a given device, but it should be noted that many apps can target Android 5 - Android 5 has plenty to offer already).

The dealbreaker for me is that the Gpu delegate is extremely restrictive. Very few models work with it. None of my models do actually. Hi @pkgoogle Is there an update on this?

Please also note that the official [documentation](https://www.tensorflow.org/lite/android/development#minimum_android_sdk_versions_for_libraries) still indicates that the `minSdkVersion` is 19. We are going to fix this.

I have been discussing this with the TF Lite team, and we have consensus that this is a problem that should be fixed.
I have analyzed the cause and possible solutions, and produced a prototype solution that allows use of AHardwareBuffer on versions of Android that support it while still remaining compatible with earlier versions of Android back to Android API level 21.  A TF Lite team member (@[turbotoribio](https://github.com/tensorflow/tensorflow/commits?author=turbotoribio)) has taken on the remaining tasks to get this fix landed.

The main part of the fix has landed:
https://github.com/tensorflow/tensorflow/commit/c7c3135b2802f3b8886f2ecefc39de49799b1e9b

The remaining parts are to change ANDROID_NDK_API_LEVEL from 26 back to 21.

The fix will be included in TF Lite 2.16. Thanks for the reply @fergushenderson. That is a great news!
Are you also considering patching the previous versions, namely 2.12.0, 2.13.0, 2.14.0?
 We are _considering_ patching 2.15, since that could be shipped a lot sooner than 2.16.

There doesn't seem to be much benefit from patching 2.12-2.14, since users who are affected by this issue could just use 2.15 instead.  (But please correct me if I am wrong about that.) @fergushenderson Do we know when the version 2.15 can be released on Maven central? @fergushenderson Our project needs version 2.15 please help me to answer the release date @fergushenderson I have just tried tensorflow-lite version 2.15.0. Now I am getting the following compilation error:

```
> Failed to transform guice-5.1.0.jar (com.google.inject:guice:5.1.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/nijatahmadli/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/5.1.0/da25056c694c54ba16e78e4fc35f17fc60f0d1b4/guice-5.1.0.jar.
         > Error while dexing.
           Increase the minSdkVersion to 26 or above.
```
Looks like `guice` was introduced in 2.15.0 and requires minSdkVersion 26 which I guess stems from the use of Java 8 language features. Unfortunately, upgrading to 26 is not an option for our project.  @fergushenderson I have the same issue with @nijat-ahmadli. Please support us > @fergushenderson I have just tried tensorflow-lite version 2.15.0. Now I am getting the following compilation error:
> 
> ```
> > Failed to transform guice-5.1.0.jar (com.google.inject:guice:5.1.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
>       > Execution failed for DexingWithClasspathTransform: /Users/nijatahmadli/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/5.1.0/da25056c694c54ba16e78e4fc35f17fc60f0d1b4/guice-5.1.0.jar.
>          > Error while dexing.
>            Increase the minSdkVersion to 26 or above.
> ```
> 
> Looks like `guice` was introduced in 2.15.0 and requires minSdkVersion 26 which I guess stems from the use of Java 8 language features. Unfortunately, upgrading to 26 is not an option for our project.

Same problem here.  Thanks for raising that issue with the guice dependency.  I have alerted the TensorFlow Lite team of this new issue.

The tensorflow 2.16.0 preview release is out.  Is the issue still reproducible in 2.16.0?

In general it is possible to use (most) Java 8 language features while depending only on API level 21, rather than 26.
See <https://developer.android.com/studio/write/java8-support> for details.
So if guice is using Java 8 language features, that doesn't necessarily mean that it needs to be incompatible with API level 21.
 I have a problem too, I think it's the same problem
ERROR:C:\Users\hp\.gradle\caches\transforms-3\0e1dbadb4b8b682380e0f29f2a20be93\transformed\jetified-guice-5.1.0.jar: D8: com.android.tools.r8.internal.a2: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform guice-5.1.0.jar (com.google.inject:guice:5.1.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: C:\Users\hp\.gradle\caches\transforms-3\0e1dbadb4b8b682380e0f29f2a20be93\transformed\jetified-guice-5.1.0.jar.
         > Error while dexing. According to the error messages, guice-5.1.0.jar is not compatible with Android 21. The Java support 8 of Android by desugaring seems not working with guice-5.1.0.jar, could you please consider removing it from the dependency list of tensorflow-lite?

> @fergushenderson I have just tried tensorflow-lite version 2.15.0. Now I am getting the following compilation error:
> 
> ```
> > Failed to transform guice-5.1.0.jar (com.google.inject:guice:5.1.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.
>       > Execution failed for DexingWithClasspathTransform: /Users/nijatahmadli/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/5.1.0/da25056c694c54ba16e78e4fc35f17fc60f0d1b4/guice-5.1.0.jar.
>          > Error while dexing.
>            Increase the minSdkVersion to 26 or above.
> ```
> 
> Looks like `guice` was introduced in 2.15.0 and requires minSdkVersion 26 which I guess stems from the use of Java 8 language features. Unfortunately, upgrading to 26 is not an option for our project.


### 1. System information

- OS Platform and Distribution: Android 5.1, OPPO device
- TensorFlow library : Tensorflow lite 2.13.0

When I try to load model and get error:

`E/art: dlopen("/data/app/com.app.demo-1/lib/arm64/libtensorflowlite_jni.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "strtod_l" referenced by "/data/app/com.app.demo-1/lib/arm64/libtensorflowlite_jni.so"...`