I have two dependencies 'org.tensorflow:tensorflow-lite:1.15.0'
and 'org.tensorflow:tensorflow-lite-task-vision:0.3.0'
so when I add these in build.gradle
file. and sync the project. It is showing -->
Duplicate class org.tensorflow.lite.DataType found in modules jetified-tensorflow-lite-1.15.0-runtime (org.tensorflow:tensorflow-lite:1.15.0)
and jetified-tensorflow-lite-api-2.7.0-runtime (org.tensorflow:tensorflow-lite-api:2.7.0)
Duplicate class org.tensorflow.lite.DataType$1 found in modules jetified-tensorflow-lite-1.15.0-runtime (org.tensorflow:tensorflow-lite:1.15.0)
and jetified-tensorflow-lite-api-2.7.0-runtime (org.tensorflow:tensorflow-lite-api:2.7.0)
Duplicate class org.tensorflow.lite.Delegate found in modules jetified-tensorflow-lite-1.15.0-runtime (org.tensorflow:tensorflow-lite:1.15.0)
and jetified-tensorflow-lite-api-2.7.0-runtime (org.tensorflow:tensorflow-lite-api:2.7.0)
Duplicate class org.tensorflow.lite.Tensor found in modules jetified-tensorflow-lite-1.15.0-runtime (org.tensorflow:tensorflow-lite:1.15.0) and jetified-tensorflow-lite-api-2.7.0-runtime (org.tensorflow:tensorflow-lite-api:2.7.0)
How to resolve this dependency error. I have tried by adding one one dependencies and now I am getting that error causes by adding this dependency 'org.tensorflow:tensorflow-lite-task-vision:0.3.0'
By removing one of these dependencies I'm getting error in my java files.
My build.gradle
file
apply plugin: 'com.android.application'
//apply plugin: 'de.undercouch.download'
android {
compileSdkVersion 31
defaultConfig {
applicationId "org.tensorflow.lite.examples.detection"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
noCompress "tflite"
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
lintOptions {
abortOnError false
}
android {
ndkVersion '21.1.6528147'
}
flavorDimensions "tfliteInference"
productFlavors {
// The TFLite inference is built using the TFLite Java interpreter.
interpreter {
dimension "tfliteInference"
}
// Default: The TFLite inference is built using the TFLite Task library (high-level API).
taskApi {
getIsDefault().set(true)
dimension "tfliteInference"
}
}
}
// import DownloadModels task
project.ext.ASSET_DIR = projectDir.toString() + '/src/main/assets'
project.ext.TMP_DIR = project.buildDir.toString() + '/downloads'
// Download default models; if you wish to use your own models then
// place them in the "assets" directory and comment out this line.
apply from:'download.gradle'
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.android.gms:play-services-vision-common:19.1.3'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
def camerax_version = "1.0.0-beta07"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'org.tensorflow:tensorflow-lite:1.15.0'
implementation 'org.tensorflow:tensorflow-lite-support:0.0.0-nightly-SNAPSHOT'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.9.0'
implementation 'org.tensorflow:tensorflow-lite-task-vision:0.3.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'com.google.truth:truth:1.0.1'
androidTestImplementation 'androidx.test:rules:1.1.0'
}