Files
VibeCoding/WebRTCControlled/app/build.gradle
TongTongStudio ded6fe5ab7 feat(android): add device activation flow and update dependencies
重构项目架构,引入启动页(SplashActivity)检查激活状态,未激活设备引导至激活页(ActivationActivity)完成provision+token流程。集成Retrofit+RxJava3网络层、Room数据库、Lifecycle组件、MMKV等依赖,升级OkHttp/Gson版本,并将构建配置从旧项目全面迁移至新项目结构。
2026-08-03 00:25:51 +08:00

207 lines
7.2 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
plugins {
id 'com.android.application'
id 'com.google.protobuf'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.kapt'
}
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
def appName() {
return "WebRTCControlled"
}
android {
namespace 'com.ttstd.controlled'
compileSdk 34
defaultConfig {
applicationId "com.ttstd.controlled"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
// 服务端地址(信令 wss 与 HTTP api 同源)。部署时通过 flavor / CI 注入真实值。
buildConfigField "String", "API_BASE", "\"http://192.168.5.224:8080\""
// 出厂预置共享密钥(用于 provision 签名)。正式发布必须替换并通过安全方式注入。
buildConfigField "String", "DEVICE_PROVISION_SECRET", "\"dev-device-provision-secret-change-me\""
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
dataBinding true
buildConfig true
aidl true
}
sourceSets {
zhanRuiDebug.manifest.srcFile 'src/system/AndroidManifest.xml'
zhanRuiRelease.manifest.srcFile 'src/system/AndroidManifest.xml'
CrosshatchDebug.manifest.srcFile 'src/system/AndroidManifest.xml'
CrosshatchRelease.manifest.srcFile 'src/system/AndroidManifest.xml'
}
signingConfigs {
keypub {
storeFile file(rootProject.ext.signingConfigs.keypub.storeFile)
storePassword rootProject.ext.signingConfigs.keypub.storePassword
keyAlias rootProject.ext.signingConfigs.keypub.keyAlias
keyPassword rootProject.ext.signingConfigs.keypub.keyPassword
}
crosshatch {
storeFile file(rootProject.ext.signingConfigs.crosshatch.storeFile)
storePassword rootProject.ext.signingConfigs.crosshatch.storePassword
keyAlias rootProject.ext.signingConfigs.crosshatch.keyAlias
keyPassword rootProject.ext.signingConfigs.crosshatch.keyPassword
}
zhanxun {
storeFile file(rootProject.ext.signingConfigs.zhanxun.storeFile)
storePassword rootProject.ext.signingConfigs.zhanxun.storePassword
keyAlias rootProject.ext.signingConfigs.zhanxun.keyAlias
keyPassword rootProject.ext.signingConfigs.zhanxun.keyPassword
}
}
buildTypes {
zhanRuiDebug.initWith(debug)
zhanRuiDebug {
debuggable true
signingConfig signingConfigs.zhanxun
}
zhanRuiRelease.initWith(release)
zhanRuiRelease {
signingConfig signingConfigs.zhanxun
}
CrosshatchDebug.initWith(debug)
CrosshatchDebug {
debuggable true
signingConfig signingConfigs.crosshatch
}
CrosshatchRelease.initWith(release)
CrosshatchRelease {
signingConfig signingConfigs.crosshatch
}
debug {
versionNameSuffix "_debug"
debuggable true
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
signingConfig signingConfigs.keypub
}
release {
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
//前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//签名
signingConfig signingConfigs.keypub
}
}
// Add application variant configuration here instead
applicationVariants.all { variant ->
variant.outputs.each { output ->
def buildType = variant.buildType.name
if (buildType.contains("debug")) {
output.outputFileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk"
} else {
output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
}
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.25.1'
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {}
}
}
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.multidex:multidex:2.0.1"
implementation "androidx.recyclerview:recyclerview:1.1.0"
// Room依赖
implementation "androidx.room:room-runtime:2.8.4"
implementation "androidx.room:room-rxjava3:2.8.4"
kapt "androidx.room:room-compiler:2.8.4"
// ViewModel和LiveData
implementation "androidx.lifecycle:lifecycle-viewmodel:2.10.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.10.0"
implementation "androidx.lifecycle:lifecycle-runtime:2.10.0"
kapt "androidx.lifecycle:lifecycle-compiler:2.10.0"
// LifecycleService 核心库
implementation "androidx.lifecycle:lifecycle-service:2.10.0"
// 安全存储:加密 SharedPreferences保存激活得到的 deviceSecret / deviceUid / accessToken
implementation 'androidx.security:security-crypto:1.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//RxJava
implementation 'io.reactivex.rxjava3:rxjava:3.1.12'
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'
implementation 'com.squareup.moshi:moshi:1.15.2'
implementation 'com.squareup.okhttp3:okhttp:5.3.2'
implementation 'com.squareup.okhttp3:logging-interceptor:5.3.2'
implementation 'com.squareup.retrofit2:retrofit:3.0.0'
implementation 'com.squareup.retrofit2:converter-gson:3.0.0'
// implementation 'com.squareup.retrofit2:adapter-rxjava2:3.0.0'
implementation "com.squareup.retrofit2:adapter-rxjava3:3.0.0"
// Gson for JSON信令消息仍使用 JSON
implementation 'com.google.code.gson:gson:2.14.0'
// ProtobufDataChannel 控制指令二进制)
implementation 'com.google.protobuf:protobuf-java:3.25.1'
// WebRTC
implementation 'io.github.webrtc-sdk:android:144.7559.09'
// implementation 'org.webrtc:google-webrtc:1.0.32006'
//生命周期管理
implementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2'
implementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2'
implementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2'
implementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2'
implementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2'
//glide
implementation 'com.github.bumptech.glide:glide:4.15.1'
kapt 'com.github.bumptech.glide:compiler:4.15.1'
implementation 'com.tencent:mmkv-static:2.4.0'
}