0

My Android project has a dependency on third-party SDK, which internally is using TensorFlow lite. Now I already have my application running without issue on an Android device but as soon as I update the third-party library, rebuild and run the project, I start seeing the below crash and the app isn't able to start on the device.

Caused by: java.lang.IncompatibleClassChangeError: Found interface org.tensorflow.lite.Tensor, but class was expected (declaration of 'org.tensorflow.lite.Tensor' appears in /data/app/~~v0-rg==/com.dummy.sampleapp-yRZ==/base.apk!classes19.dex)
    at com.sdk.ondevicefull.k.a(SourceFile:2031)
    at com.sdk.ondevicefull.k.b(SourceFile:43)
    at com.sdk.ondevicefull.k.a(SourceFile:24)
    at com.sdk.ondevicefull.g.c(SourceFile:2284)
    at com.sdk.ondevicefull.g.d(SourceFile:382)
    at com.sdk.ondevicefull.g$a.a(SourceFile:404)
    at com.sdk.events.d$4.run(SourceFile:502)
    at com.sdk.threading.executors.Executors$1.run(SourceFile:223)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    at ....

What could be causing this error? could there be something missing with the new update of SDK itself? Can I take any measures in my app to prevent it?

  • Looks like your gradle has two different versions of tensor flow, when you build you get different definition (interface vs class). I believe you must match the tensorflow to one that is in third party libraries. – Quantum_VC May 17 '22 at 06:25
  • @Quantum_VC I checked my Gradle file and found only one version of tenser flow. Is there a particular way to cross-check which version of tensor flow a Gradle has? – CodingWithLearner May 17 '22 at 15:27
  • https://stackoverflow.com/questions/28444016/how-can-i-force-gradle-to-set-the-same-version-for-two-dependencies – Quantum_VC May 17 '22 at 17:32
  • @Quantum_VC So I figured that the new version of the third party has not changed the TensorFlow version; it is still the old one. So I wonder why this error only started with this new lib version. – CodingWithLearner May 18 '22 at 04:35
  • @Quantum_VC I have also noticed in the dependency tree that 1] when I use tensorflow-lite version 2.8.0 in my app, it creates two dependencies for third-party SDK : `org.tensorflow:tensorflow-lite:2.2.0 -> 2.8.0 org.tensorflow:tensorflow-lite-api:2.8.0` 2] but when I use tensorflow-lite version 2.5.0 in my app, it only creates one dependency for third-party sdk `org.tensorflow:tensorflow-lite:2.2.0 -> 2.5.0` I wonder why this dependency tree is mismatched between two versions! Any suggestions? – CodingWithLearner May 18 '22 at 05:20
  • You can refer to the release log: https://github.com/tensorflow/tensorflow/releases – Quantum_VC May 18 '22 at 22:10

0 Answers0