89 lines
2.8 KiB
Kotlin
89 lines
2.8 KiB
Kotlin
plugins {
|
|
id("com.android.application")
|
|
id("org.jetbrains.kotlin.android")
|
|
}
|
|
|
|
android {
|
|
namespace = "com.photobooth.app"
|
|
compileSdk = 34
|
|
|
|
defaultConfig {
|
|
applicationId = "com.photobooth.app"
|
|
minSdk = 26 // Android 8.0 trở lên để hỗ trợ tốt các tính năng đồ họa
|
|
targetSdk = 34
|
|
versionCode = 1
|
|
versionName = "1.0"
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro"
|
|
)
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
buildFeatures {
|
|
viewBinding = true // Bật ViewBinding để thao tác với giao diện dễ dàng
|
|
}
|
|
sourceSets {
|
|
getByName("main") {
|
|
assets.srcDirs("../../assets")
|
|
}
|
|
}
|
|
@Suppress("DEPRECATION")
|
|
aaptOptions {
|
|
noCompress("tflite")
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation("androidx.core:core-ktx:1.12.0")
|
|
implementation("androidx.appcompat:appcompat:1.6.1")
|
|
implementation("com.google.android.material:material:1.11.0")
|
|
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
|
|
|
|
// --- Thư viện CameraX Core ---
|
|
val cameraVersion = "1.3.1"
|
|
implementation("androidx.camera:camera-core:$cameraVersion")
|
|
implementation("androidx.camera:camera-camera2:$cameraVersion")
|
|
implementation("androidx.camera:camera-lifecycle:$cameraVersion")
|
|
implementation("androidx.camera:camera-view:$cameraVersion")
|
|
implementation("androidx.camera:camera-extensions:$cameraVersion")
|
|
|
|
|
|
|
|
// --- Google MediaPipe Tasks Vision ---
|
|
implementation("com.google.mediapipe:tasks-vision:0.10.14")
|
|
|
|
// --- TensorFlow Lite ---
|
|
implementation("org.tensorflow:tensorflow-lite:2.14.0")
|
|
implementation("org.tensorflow:tensorflow-lite-gpu:2.14.0")
|
|
}
|
|
tasks.register("downloadAiModels") {
|
|
group = "ai_lifecycle"
|
|
description = "Tự động kích hoạt script Python tải và chuyển đổi mô hình TFLite sạch."
|
|
|
|
doLast {
|
|
println("🤖 [Gradle AI Engine] Đang kích hoạt script Python...")
|
|
exec {
|
|
commandLine("python", "${project.rootDir}/../download_and_export_models.py")
|
|
}
|
|
println("✅ [Gradle AI Engine] Tiến trình đồng bộ tài nguyên AI hoàn tất!")
|
|
}
|
|
}
|
|
|
|
// 2. KHẮC PHỤC LỖI KHÔNG TÌM THẤY: Ép mô-đun :app chạy task AI trước khi build mã nguồn Android
|
|
tasks.named("preBuild") {
|
|
dependsOn("downloadAiModels")
|
|
} |