DuplicateRelativePath when build android app
eomgerm opened this issue · 1 comments
eomgerm commented
Hello!
Currently, I'm working on developing android camera application using depthai library.
I added depthai-platfrom
& opencv-platform
to use them, but when I build the app, gradle throws DuplicateRelativeFileException
.
I tried all of things to solve this but I couldn't...
please help me
My build.gradle.kts
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.compose.compiler)
id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
kotlin("plugin.serialization") version "2.0.0"
id("org.bytedeco.gradle-javacpp-platform") version "1.5.10"
}
extra["javacppPlatform"] = "android-arm64"
android {
namespace = "com.nsonesoft.smartk9"
compileSdk = 34
defaultConfig {
applicationId = "com.nsonesoft.smartk9"
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
debug {
buildConfigField("String", "BASE_URL", "\"http://teams.nsonesoft.com:9090\"")
buildConfigField("String", "BASE_WS_URL", "\"ws://teams.nsonesoft.com:9090\"")
buildConfigField("String", "BASE_STREAM_URL", "\"rtsp://teams.nsonesoft.com:60921\"")
}
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
// TODO: 배포 URL로 변경할 것
buildConfigField("String", "BASE_URL", "\"http://teams.nsonesoft.com:9090\"")
buildConfigField("String", "BASE_WS_URL", "\"ws://teams.nsonesoft.com:9090\"")
buildConfigField("String", "BASE_STREAM_URL", "\"rtsp://teams.nsonesoft.com:60921\"")
}
}
buildFeatures {
buildConfig = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
configurations {
create("javacpp")
}
tasks.register<Copy>("javacppExtract") {
dependsOn(configurations.getByName("javacpp"))
from(configurations.getByName("javacpp").map { zipTree(it) })
include("lib/**")
into("$layout.buildDirectory/javacpp/")
android.sourceSets["main"].jniLibs.srcDirs("$layout.buildDirectory/javacpp/lib/")
tasks.named("preBuild").configure {
dependsOn(this@register)
}
}
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.okhttp)
implementation(libs.hilt.android)
implementation(libs.androidx.camera.video)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.ui.text.google.fonts)
ksp(libs.hilt.compiler)
implementation(libs.androidx.runtime.livedata)
implementation(libs.androidx.camera.core)
implementation(libs.androidx.camera.camera2)
implementation(libs.androidx.camera.lifecycle)
implementation(libs.root.encoder)
implementation(libs.androidx.material.icons.extended)
implementation(libs.libausbc)
implementation(libs.libnative)
implementation(libs.libuvc)
implementation(libs.rtsp.server)
implementation(libs.kotlinx.serialization.json)
implementation(libs.okhttp.http.logging.interceptor)
implementation(libs.retrofit)
implementation("io.socket:socket.io-client:1.0.1") {
exclude(group = "org.json", module = "json")
}
implementation(libs.timber)
implementation(libs.androidx.startup.runtime)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.sandwich.retrofit)
implementation(libs.moshi)
implementation(libs.moshi.adapters)
implementation(libs.moshi.kotlin)
implementation(libs.converter.moshi)
ksp(libs.moshi.codegen)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.opencv.platform)
implementation(libs.depthai.platform)
api(libs.javacpp)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
Gradle Logs
Caused by: com.android.builder.merge.DuplicateRelativeFileException: 4 files found with path 'META-INF/native-image/android-arm64/jnijavacpp/jni-config.json' from inputs:
- /Users/eomgerm/.gradle/caches/modules-2/files-2.1/org.bytedeco/opencv/4.9.0-1.5.10/fdf4df79cf646dc2da9f6e38edce57a375b97196/opencv-4.9.0-1.5.10-android-arm64.jar
- /Users/eomgerm/.gradle/caches/modules-2/files-2.1/org.bytedeco/depthai/2.24.0-1.5.10/832ea03eb3b962ea64faa95b343cb6638af99854/depthai-2.24.0-1.5.10-android-arm64.jar
- /Users/eomgerm/.gradle/caches/modules-2/files-2.1/org.bytedeco/openblas/0.3.26-1.5.10/397b375687a7ddbc013151246a6343efc7188693/openblas-0.3.26-1.5.10-android-arm64.jar
- /Users/eomgerm/.gradle/caches/modules-2/files-2.1/org.bytedeco/javacpp/1.5.10/ab5d3badd1f79925ad858ada6f500915ea3b58b6/javacpp-1.5.10-android-arm64.jar
saudet commented
Try to do use a javacppExtract task like this here: https://github.com/bytedeco/gradle-javacpp#the-platform-plugin