在尝试运行Flutter应用程序时出现此错误,尝试了不同的方法,但到目前为止没有任何效果

9udxz4iz  于 2023-05-08  发布在  Flutter
关注(0)|答案(1)|浏览(295)

因此,我试图在vscode上运行我的应用程序,并不断收到以下错误:评估项目“:tflite”时出现问题。
在类型为org. gradle. api. internal. artifacts. dsl. dependencies. DefaultDependencyHandler的对象上找不到参数[org.tensorflow:tensorflow-lite:+]的方法compile()。
尽管我已经做了一些修改,把compile()方法改成了implementation。下面是我的app/build.gradle文件:

type `def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {`
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    aaptOptions {
        noCompress 'tflite'
        noCompress 'lite'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.flutterappdemo"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 23
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.tensorflow:tensorflow-lite:+"
    implementation "org.tensorflow:tensorflow-lite-gpu:+"
    implementation "com.google.android.gms:play-services-tflite-gpu:16.0.0-beta03" 
}
here

任何帮助将不胜感激!

nbnkbykc

nbnkbykc1#

我建议运行flutter doctor -v,看看这个问题是否与Flutter安装本身有关。

相关问题