feat(android): libbox 隧道重写对接真实 1.13.12 API,APK 编译通过(Task 5)
原生层照 PoC 旧/想象 API 写,与真实 sing-box 1.13.12 libbox 差距是架构级: - 包名 libbox(非 go.libbox);无 BoxService,改 Libbox.setup + CommandServer 模型 - PangolinVpnService 重写:实现完整 PlatformInterface(15法)+CommandServerHandler - 新增 DefaultNetworkMonitor(上报默认接口,缺则报 no available network) - openTun 适配真实 TunOptions(RoutePrefixIterator/getMTU/StringBox DNS) - 统计/切节点经 CommandClient(uplinkTotal/selectOutbound);MainActivity 接线 构建环境矩阵打通:Gradle 8.7(Java21)+声明式插件迁移+AGP 8.6+Kotlin 2.2.0+占位图标 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
plugins {
|
||||
id "com.android.application"
|
||||
id "kotlin-android"
|
||||
id "dev.flutter.flutter-gradle-plugin"
|
||||
}
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
@@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
|
||||
}
|
||||
}
|
||||
|
||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||
if (flutterRoot == null) {
|
||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||
}
|
||||
|
||||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||
if (flutterVersionCode == null) {
|
||||
flutterVersionCode = '1'
|
||||
@@ -21,10 +22,6 @@ if (flutterVersionName == null) {
|
||||
flutterVersionName = '1.0'
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
android {
|
||||
namespace "com.pangolin.pangolin_vpn"
|
||||
compileSdkVersion flutter.compileSdkVersion
|
||||
@@ -57,17 +54,6 @@ android {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
|
||||
// libbox.aar 包含 arm64-v8a / armeabi-v7a / x86_64 三个 ABI;
|
||||
// 若只需调试,可缩减 abiFilters 以加快构建速度。
|
||||
// splits {
|
||||
// abi {
|
||||
// enable true
|
||||
// reset()
|
||||
// include 'arm64-v8a', 'x86_64'
|
||||
// universalApk true
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
flutter {
|
||||
@@ -75,21 +61,15 @@ flutter {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
|
||||
// ── sing-box libbox(gomobile AAR)──────────────────────────────
|
||||
// 产物由 app/kernel/build-android.sh 生成:
|
||||
// cd app/kernel && ./build-android.sh
|
||||
// 产物路径(相对于本 build.gradle):../../../app/kernel/dist/android/libbox.aar
|
||||
//
|
||||
// 若文件不存在,构建会报错:请先运行 build-android.sh 生成产物。
|
||||
// 路径说明:client/android/app → ../../.. → repo root → app/kernel/dist/android/
|
||||
// 路径:client/android/app → ../../.. → repo root → app/kernel/dist/android/
|
||||
// Kotlin stdlib 由 kotlin-android 插件自动引入,无需显式声明。
|
||||
def libboxAar = file("${projectDir}/../../../app/kernel/dist/android/libbox.aar")
|
||||
if (libboxAar.exists()) {
|
||||
implementation files(libboxAar)
|
||||
} else {
|
||||
// AAR 尚未构建 — 保留占位;IDE 会报红线,但不影响非 libbox 代码编辑。
|
||||
// 运行 `app/kernel/build-android.sh` 后重新 sync 即可。
|
||||
logger.warn("⚠ libbox.aar not found at ${libboxAar.absolutePath}")
|
||||
logger.warn(" Run: cd app/kernel && ./build-android.sh")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user