fluttergradleandroid-gradle-plugintensorflow-lite

How to convert tensor flow lite plugin in non imperative syntax for flutter


As imperative declaration is deprecated, I try to convert my plugins without success (semicolon isn't supported):

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0" // OK
    id "com.android.application" version "7.3.0" apply false // OK
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false //OK
    id "org.tensorflow:tensorflow-lite" version "0.1.100" apply false // KO
    id "org.tensorflow:tensorflow-lite-select-tf-ops" version "0.1.100" apply false // KO

}

I also tried this without success:

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0" // OK
    id "com.android.application" version "7.3.0" apply false // OK
    id "org.jetbrains.kotlin.android" version "1.7.10" apply false // OK
    id "org.tensorflow.tensorflow.lite" version "0.1.100" apply false // KO
    id "org.tensorflow.tensorflow.lite.select.tf.ops" version "0.1.100" apply false // KO

}

Solution

  • Deprecation of imperative plugins declaration influences only plugins. Those tensorflow artefacts belongs to dependencies block in your build.gradle, since they are runtime dependencies of your app, and not build-time dependencies of your build.

    So, you plugins block should remain like this:

    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "7.3.0" apply false
        id "org.jetbrains.kotlin.android" version "1.7.10" apply false
    }
    

    And tensorflow dependencies in dependencies block:

    dependencies {
        // using latest version from maven-central
        implementation 'org.tensorflow:tensorflow-lite:2.16.1'
        implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:2.16.1'
    
    }