我尝试使用 tflite 包来创建活动对象检测应用程序,但似乎在我安装了这两个包:tflite,并且还编写了检测代码后,它似乎没有运行。
请帮忙。我已经寻找解决方案一周了,但还没有找到🥹。
问题:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':tflite'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Specify a namespace in the module's build file. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
android/app/build.gradle
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
android {
namespace "com.example.application"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.application"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
signingConfig = signingConfigs.debug
}
}
}
flutter {
source = "../.."
}
android/settings.gradle
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}
include ":app"
pubspec.yaml
cupertino_icons: ^1.0.8
flutter_svg: ^2.0.10+1
image_picker: ^1.1.2
camera: ^0.11.0+2
tflite: ^1.1.2
~flite-1.1.2 ndroid uild.gradle:
group 'sq.flutter.tflite'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
lintOptions {
disable 'InvalidPackage'
}
dependencies {
implementation 'org.tensorflow:tensorflow-lite:+'
implementation 'org.tensorflow:tensorflow-lite-gpu:+'
}
}
有人可以帮助我吗?谢谢你
该问题是由于您的项目中使用的 Android Gradle Plugin (AGP) 版本与 tflite 包不匹配导致的。 tflite 包使用的是过时的 AGP 版本 (3.6.3),而您的应用程序使用的是更新的版本 (8.1.0)。
更新您的 pubspec.yaml
cupertino_icons:^1.0.8 flutter_svg:^2.0.10+1 图像选择器:^1.1.2 相机:^0.11.0+2 tflite: git: 网址:https://github.com/tech-ramakant/flutter_tflite.git 参考:命名空间_未指定_修复
更新应用程序的 build.gradle -> 从 minSdkVersion 15 到 minSdkVersion 19,然后按照以下命令操作
扑扑干净 扑扑酒吧得到 扑腾跑