Stack Exchange
Build fail when using Tensorflow lite metadata in Android Studio 4.1
guys, I am new to Stackoverflow
A question about using Tensorflow lite in AS4.1
As I "new" -> "other" -> "tensorflow lite model" and import a new .tflite file
The project automatically generate a PosenetMobilenetFloat0751Metadata1.java file
Then "build" -> "Make project", it shows error:
package org.tensorflow.lite.support.metadata does not exist import org.tensorflow.lite.support.metadata.MetadataExtractor;
The error happens in PosenetMobilenetFloat0751Metadata1.java:
import org.tensorflow.lite.support.metadata.MetadataExtractor;

This error seems come from I don't have this dependency,
following is my dependencies in build.gradle
dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation project(":posenet")
  implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  implementation 'androidx.appcompat:appcompat:1.1.0'
  implementation 'androidx.core:core-ktx:1.1.0'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  implementation 'org.tensorflow:tensorflow-lite:1.12.0'
  implementation 'org.tensorflow:tensorflow-lite-gpu:2.2.0'
  implementation 'org.tensorflow:tensorflow-lite-support:0.0.0-nightly'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test:runner:1.2.0'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

Can Someone help me how to go next?

I think you need to use implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2'

WOW, You're right, I pass the 'Make project"

I think you need to use implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc2'.

There are newer artifacts than 0.1.0-rc2...Check https://mvnrepository.com/artifact/org.tensorflow/tensorflow-lite-metadata

Please try to add this
configurations {

    libMetadata
}


dependencies {

    libMetadata 'org.tensorflow:tensorflow-lite-support:0.0.0-experimental-metadata-monolithic'
}


task downloadLibs(type: Sync) {

    from configurations.libMetadata

    into "$buildDir/libs"

    rename 'tensorflow-lite-support-0.0.0-experimental-metadata-monolithic.jar', "tensorflow-lite-support-metadata.jar"
}

Careful when adjust another version, this very sensitive as BUILD!
