Cannot currently create HexagonDelegate, but was working in the past
@ioannispan,
Could you you make sure that you're using the latest nightlies - may be clear the gradle cash ?

We just cloned tensorflow examples and updated image classification example to include hexagon. I followed the [guide](https://www.tensorflow.org/lite/performance/hexagon_delegate#hexagon_delegate_java_api)

by adding the gradle dep in build.gradle

and created directory jniLibs/arm64-v8a and included the files i got from the libhexagon_nn_skel extraction. as explained [here](https://www.tensorflow.org/lite/performance/hexagon_delegate#add_the_shared_library_to_your_app)

Also please have a look at this issue https://github.com/tensorflow/tensorflow/issues/55364 and https://github.com/tensorflow/tensorflow/issues/53380 for the reference. Thank you! @tilakrayal 
I've cleared the gradle cache and done all the steps in the guide, but the error persists. The issues you stated did not help.

**UPDATE**
I've tried using the TFLite Model Benchmark Tool with Android Apk (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/tools/benchmark/android) to see if i'll have the same issue with Hexagon. In order to be able to use the Hexagon delegate i do the following:

```
adb push libhexagon_interface.so /data/local/tmp
adb push libhexagon_nn_skel.so /data/local/tmp
adb push libhexagon_nn_skel_v65.so /data/local/tmp
adb push libhexagon_nn_skel_v66.so /data/local/tmp
```

where `libhexagon_interface.so` comes from [this link](https://storage.googleapis.com/tensorflow-nightly-public/prod/tensorflow/release/lite/tools/nightly/latest/android_aarch64_libhexagon_interface.so) from [this guide](https://www.tensorflow.org/lite/performance/measurement) and `libhexagon_nn_skel(_v65/6).so` come from [this link](https://storage.cloud.google.com/download.tensorflow.org/tflite/hexagon_nn_skel_v1.20.0.1.run) (v1.20.0.1) from [this guide](https://www.tensorflow.org/lite/android/delegates/hexagon).

 When i set `use_hexagon=true` and **don't** specify the `hexagon_lib_path`, then the path is set to:

`I tflite  : Hexagon lib path: [/data/app/~~K6aeHsxXcgmL2FRThR7mBQ==/org.tensorflow.lite.benchmark-tPmERhUnFAHAenBJZq4OQw==/lib/arm64]`

and i get the error:

```
W tflite  : Failed to fetch Hexagon NN version. This might be because you're using incompatible versions of libhexagon_interface and libhexagon_nn_skel. You must use compatible versions. Refer to Tensorflow Lite Hexagon Delegate Guide.
I tflite  : Hexagon Delegate is not supported.
W tflite  : Could not create Hexagon delegate: platform may not support delegate or required libraries are missing
```

But when i specify `hexagon_lib_path=/data/local/tmp/`, then the delegate is applied succesfully:

```
I tflite  : Hexagon delegate created.
I tflite  : TfLiteHexagonDelegate delegate: 61 nodes delegated out of 61 nodes with 1 partitions.
I tflite  : Replacing 61 out of 61 node(s) with delegate (TfLiteHexagonDelegate) node, yielding 1 partitions for the whole graph.
```

Does this help with the problem in my Android app in any way?
Thanks Hi @ioannispan 

Although the documentation [suggests](https://www.tensorflow.org/lite/android/delegates/hexagon#example_usage) to use v1.20.0.1 , the [config](https://github.com/tensorflow/tensorflow/blob/master/third_party/hexagon/workspace.bzl) has v1.20.0.9 as latest version to use for nightly snapshots which can be downloaded from [here](https://storage.googleapis.com/mirror.tensorflow.org/storage.cloud.google.com/download.tensorflow.org/tflite/hexagon_nn_headers_v1.20.0.9.tgz).

Could you please try with `libhexagon_interface.so` using v1.20.0.9 and see if it resolves the issue?

Thanks. Hello @pjpratik 

I think i am missing something. The link you provided for v1.20.0.9 does not contain `libhexagon_nn_skel(_v65/6).so` files.
I copy the new `libhexagon_interface.so` to my Android `jniLibs/arm64-v8a/` directory, but the error persists:

`Failed to load libhexagon_interface.so, Error: dlopen failed: library "libadsprpc.so" not found: needed by /data/app/~~3WH2wsowpMNgALxjaSkcCw==/com.example.<project>--XTLMj82qPraRQM25waMKg==/lib/arm64/libhexagon_interface.so in namespace classloader-namespace`

Should i put `libhexagon_interface.so` somewhere else?
Thank you Hi @ioannispan 

I have observed that the  path for `hexagon_lib_path` has to be `/data/local/tmp/` as per the build file for the benchmark tool.

https://github.com/tensorflow/tensorflow/blob/785f7f02f78c6af70ee79729ce95724e89a221bd/tensorflow/lite/tools/benchmark/BUILD#L38

Are per the [hexagon delegate](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/delegates/hexagon#hexagon-delegate) documentation,

>'libhexagon_interface.so' which holds the interface that the delegate uses. It must be available if you linked the hexagon_delegate library to TFLite. You can load it either from shell by overriding LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"path to the so", or add it inside your apk in a way it is available.

>'libhexagon_nn_skel(_v65/_v66).so' which holds the DSP code. Use TfLiteHexagonInitWithPath(..) and provide the path to the directory which holds the shared libraries for the Hexagon NN on device. If you're using TfLiteHexagonInit() then You will need to set environment variable "ADSP_LIBRARY_PATH" to "path_to_the_lib";/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp;/dsp Note that separator here is ';' not ':' You can push all 3 files, and the library will pick the one needed based on the runtime. Or if you are sure of what you will use on the device then push only one of them.

Could you please confirm if you are following this instructions to set `.so` files?

Thanks.
 
 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. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60407">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/60407">No</a>

<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Bug

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

org.tensorflow:tensorflow-lite:0.0.0-nightly-SNAPSHOT and org.tensorflow:tensorflow-lite-hexagon:0.0.0-nightly-SNAPSHOT with hexagon libraries v1.20.0.1

### Custom Code

Yes

### OS Platform and Distribution

Android 13

### Mobile device

Samsung Galaxy A71

### Python version

_No response_

### Bazel version

_No response_

### GCC/Compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current Behaviour?

The HexagonDelegate was working fine via a Java Android app on my device (Samsung Galaxy A71 with Snapdragon 730), but then i changed some things on the project (libraries versions, manifest) because i had issues with running some transformer models on the GPU and since then it is not working and produces the error:

Failed to load libhexagon_interface.so, Error: dlopen failed: library "libadsprpc.so" not found: needed by data/app/~~o6sPBobgR5g-DMgV2fEROg==/com.example.<project>-8QtHh6qQZAELc86wE5E8IA==/lib/arm64/libhexagon_interface.so in namespace classloader-namespace

I have also tried stable versions from 2.9.0 to 2.12.0 instead of the nightly snapshots and the error persists.

I can share my project if someone could look into it.

### Standalone code to reproduce the issue

```shell
On a Java project in Android Studio:

Follow the instructions in https://www.tensorflow.org/lite/android/delegates/hexagon#hexagon_delegate_java_api

build.gradle (:app):
def version = "0.0.0-nightly-SNAPSHOT"
implementation "org.tensorflow:tensorflow-lite:$version"
implementation "org.tensorflow:tensorflow-lite-hexagon:$version"
implementation "org.tensorflow:tensorflow-lite-select-tf-ops:$version"

After running the application on the device:

> adb shell ls /data/app/~~o6sPBobgR5g-DMgV2fEROg==/com.example.<project>-8QtHh6qQZAELc86wE5E8IA==/lib/arm64
libhexagon_interface.so
libhexagon_nn_skel.so
libhexagon_nn_skel_v65.so
libhexagon_nn_skel_v66.so
libtensorflowlite_flex_jni.so
libtensorflowlite_hexagon_jni.so
libtensorflowlite_jni.so

> adb shell cat /proc/cpuinfo | grep Hardware
Hardware        : Qualcomm Technologies, Inc SDMMAGPIE

> adb shell cat /sys/devices/soc0/soc_id
365

> adb shell getprop ro.product.device
a71

> adb shell getprop ro.board.platform
sm6150

Library "libadsprpc.so" is present in /system/vendor/lib

Code to create a HexagonDelegate:
Interpreter.Options finalOptions = new Interpreter.Options();
try {
    mHexagonDelegate = new HexagonDelegate(this);
    finalOptions.addDelegate(mHexagonDelegate);
    finalOptions.setUseXNNPACK(mOptions.useXNNPACK);
    mInterpreter = new Interpreter(mModel, finalOptions);
} catch (UnsupportedOperationException e) {
    // Hexagon delegate is not supported on this device.
    Log.e(TAG, "Hexagon delegate is not supported on this device.");
    return;
}
```


### Relevant log output

```shell
Android Studio log:

2023-04-24 09:14:43.588 19191-19449 tflite                  com.example.<project>             E  Failed to load libhexagon_interface.so, Error: dlopen failed: library "libadsprpc.so" not found: needed by /data/app/~~o6sPBobgR5g-DMgV2fEROg==/com.example.<project>-8QtHh6qQZAELc86wE5E8IA==/lib/arm64/libhexagon_interface.so in namespace classloader-namespace
2023-04-24 09:14:43.588 19191-19449 tflite                  com.example.<project>             I  Hexagon Delegate is not supported.
```
</details>