从源码构建Build from source

Flutter 打 APK,Go 编内核。Flutter for the APK, Go for the kernel.

本仓库只包含 Android 侧代码与预编译内核;内核源码在上游。

ℹ️

如果你只是想用,不用编译 —— 直接下 预编译 APK。

需要什么

依赖说明
Flutter3.x,Dart 3
Android SDKcompileSdk 按 android/app/build.gradle.kts 的要求装
JDK17
Go(可选)只有你要自己重编内核时

编译

git clone https://github.com/tianduoyuguang/SubsCheck--android.git
cd SubsCheck--android
flutter pub get
flutter build apk --release --split-per-abi \
  --target-platform android-arm,android-arm64

产物在 build/app/outputs/flutter-apk/:

app-arm64-v8a-release.apk
app-armeabi-v7a-release.apk

打模拟器用的 x86_64 包:

flutter build apk --release -PtargetAbi=x86_64

签名

release 签名配置在 android/app/build.gradle.kts 里,指向 android/keystore/subscheck-release.jks。仓储里的这个 keystore 只用于本项目自己的发布;你分发自己的构建时必须换成自己的 keystore,否则任何人都能用仓库里的私钥签出「同源」的 APK。

keytool -genkeypair -v -keystore my-release.jks \
  -keyalg RSA -keysize 2048 -validity 10000 -alias mykey

内核

预编译的 libsubscheck.so 在 android/app/src/main/jniLibs/<abi>/,对应的 android.bundle 配置里 extractNativeLibs=true —— 少了这个标志,APK 里的 .so 不会解压到磁盘,也就不能 exec。

内核源码本身不在本仓库,来自上游:

git clone https://github.com/beck-8/subs-check.git
cd subs-check
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o libsubscheck.so

编好后按 ABI 放回 jniLibs/arm64-v8a/ 或 jniLibs/armeabi-v7a/。内核是纯静态 Go 程序,不依赖 libc,因此不需要 NDK 交叉工具链。

目录速览

路径作用
lib/src/Flutter 侧:api.dart(HTTP 客户端)、exporter.dart(配置拼接)、models.dart(数据模型)、各页面
assets/config_template.yaml首次启动写出的配置模板
assets/ACL4SSR_Online_Full.yaml导出完整 mihomo 配置时拼在 proxies: 之后的规则模板
android/app/src/main/jniLibs/预编译内核
docs/android-port-status.md移植与修复的逐版本记录
✅

改完 UI 想快速验证,用 flutter run 连真机跑 debug 就够了;内核在 debug 包里同样能起,只要对应 ABI 的 jniLibs 存在。

This repository holds the Android side plus a prebuilt kernel; the kernel source lives upstream.

ℹ️

If you just want to use it, skip building — grab a prebuilt APK.

Requirements

DependencyNotes
Flutter3.x, Dart 3
Android SDKcompileSdk as required by android/app/build.gradle.kts
JDK17
Go (optional)Only when rebuilding the kernel yourself

Building

git clone https://github.com/tianduoyuguang/SubsCheck--android.git
cd SubsCheck--android
flutter pub get
flutter build apk --release --split-per-abi \
  --target-platform android-arm,android-arm64

Outputs land in build/app/outputs/flutter-apk/:

app-arm64-v8a-release.apk
app-armeabi-v7a-release.apk

For an emulator x86_64 build:

flutter build apk --release -PtargetAbi=x86_64

Signing

The release signing config in android/app/build.gradle.kts points at android/keystore/subscheck-release.jks. That keystore in the repo is for this project's own releases only; if you distribute your own build, use your own keystore, otherwise anyone can sign a "same-origin" APK with the committed private key.

keytool -genkeypair -v -keystore my-release.jks \
  -keyalg RSA -keysize 2048 -validity 10000 -alias mykey

The kernel

The prebuilt libsubscheck.so sits in android/app/src/main/jniLibs/<abi>/, and the manifest sets extractNativeLibs=true — without that flag the .so stays compressed inside the APK and cannot be execed.

The kernel source is not in this repo; it comes from upstream:

git clone https://github.com/beck-8/subs-check.git
cd subs-check
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -trimpath -ldflags "-s -w" -o libsubscheck.so

Drop the result into jniLibs/arm64-v8a/ or jniLibs/armeabi-v7a/. It is a pure static Go binary with no libc dependency, so no NDK cross toolchain is needed.

Layout

PathPurpose
lib/src/Flutter side: api.dart (HTTP client), exporter.dart (config assembly), models.dart, screens
assets/config_template.yamlTemplate written on first launch
assets/ACL4SSR_Online_Full.yamlRule template appended after proxies: for full mihomo exports
android/app/src/main/jniLibs/The prebuilt kernel
docs/android-port-status.mdVersion-by-version port and fix log
✅

For quick UI iteration, a flutter run debug build on a real device is enough — the kernel starts in debug builds too, as long as the matching ABI directory exists under jniLibs.