agent-Specialization/android-webview-app/app/build.gradle.kts
JOJO 84c40e505e feat(android): 恢复 app 源码追踪——域名构建期注入脱敏 + 应用更名 Astrion
- HOME_URL 改为构建期注入(BuildConfig):-P 参数 > local.properties > 环境变量 > 占位符
- network_security_config.xml 删除冗余 domain-config(base-config 已全局禁明文)
- README 重写:移除真实域名,补充注入方式说明
- app_name 更名为 Astrion;链接外跳系统浏览器(1.0.42)+ 1.0.43 版本
- AGENTS.md §8 补充版本检测链路说明;.gitignore 解除 android-webview-app 排除

Co-authored-by: Astrion powered by Kimi-K3 <astrion-agent@users.noreply.github.com>
2026-09-02 07:48:36 +08:00

101 lines
3.4 KiB
Plaintext
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.

import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
fun resolveConfig(name: String): String? {
return (project.findProperty(name) as String?)?.takeIf { it.isNotBlank() }
?: System.getenv(name)?.takeIf { it.isNotBlank() }
}
// 后端服务地址(构建期注入,仓库中只保留占位符):
// 优先级:-PHOME_URL 命令行参数 > local.properties 的 HOME_URL > 环境变量 HOME_URL > 占位默认值
// 自部署构建示例:./gradlew assembleRelease -PHOME_URL=https://your-server.example.com
fun resolveHomeUrl(): String {
(project.findProperty("HOME_URL") as String?)?.takeIf { it.isNotBlank() }?.let { return it }
val localPropsFile = rootProject.file("local.properties")
if (localPropsFile.exists()) {
val props = Properties()
localPropsFile.inputStream().use { props.load(it) }
props.getProperty("HOME_URL")?.takeIf { it.isNotBlank() }?.let { return it }
}
System.getenv("HOME_URL")?.takeIf { it.isNotBlank() }?.let { return it }
return "https://agent.example.com"
}
val homeUrl: String = resolveHomeUrl()
android {
namespace = "com.cyjai.agent"
compileSdk = 35
defaultConfig {
applicationId = "com.cyjai.agent"
minSdk = 24
targetSdk = 35
versionCode = 45
versionName = "1.0.43"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "HOME_URL", "\"$homeUrl\"")
}
buildFeatures {
buildConfig = true
}
signingConfigs {
create("release") {
val storeFilePath = resolveConfig("ANDROID_KEYSTORE_PATH")
val storePass = resolveConfig("ANDROID_KEYSTORE_PASSWORD")
val keyAliasValue = resolveConfig("ANDROID_KEY_ALIAS")
val keyPass = resolveConfig("ANDROID_KEY_PASSWORD")
if (!storeFilePath.isNullOrBlank()) {
storeFile = file(storeFilePath)
}
storePassword = storePass
keyAlias = keyAliasValue
keyPassword = keyPass
}
}
buildTypes {
release {
isMinifyEnabled = false
signingConfig = signingConfigs.getByName("release")
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}
dependencies {
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.activity:activity-ktx:1.9.2")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1")
// PDF 预览(不依赖浏览器)
implementation("com.github.mhiew:android-pdf-viewer:3.2.0-beta.3")
// sherpa-onnx 语音识别库(需手动下载 AAR 放到 app/libs/
// 下载地址https://huggingface.co/csukuangfj/sherpa-onnx-libs/tree/main/android/aar
// 下载最新 sherpa-onnx-*.aar 放到 app/libs/ 目录即可
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))
}