Build without on-device ML, arm64 only

Replace llamadart, flutter_onnxruntime and flutter_langdetect with
API-compatible stubs via dependency_overrides, so llama.cpp, LiteRT-LM
and ONNX Runtime are not packaged. Translation and the neural image
codec become unavailable; both are off by default upstream.

Also drop non-arm64 prebuilt plugin libraries at packaging time.
APK: 340 MB -> 39.5 MB, flutter test 909/909 passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-10-19 11:59:53 +02:00
1 parent 3bee159c4f
commit 42e4a1e0de
9 files changed
+144

No files matched your search

+8
View File
@@ -28,6 +28,14 @@ android {
jvmTarget = JavaVersion.VERSION_17.toString()
}
// tth fork: abiFilters does not reach prebuilt plugin .so files
// (mlkit barhopper, flserial, ...), so drop the other ABIs at packaging.
packaging {
jniLibs {
excludes += listOf("lib/armeabi-v7a/**", "lib/x86/**", "lib/x86_64/**")
}
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.meshcore.meshcore_open"
+9
View File
@@ -188,3 +188,12 @@ build_pipe:
# Strongly recommended: disables the default service worker which often causes more cache headaches
add_version_query_param: true
# This is the key flag! It appends ?v=<your pubspec version> to bootstrap/JS files
# tth fork: native ML packages replaced by stubs, see stubs/README.md
dependency_overrides:
llamadart:
path: stubs/llamadart
flutter_onnxruntime:
path: stubs/flutter_onnxruntime
flutter_langdetect:
path: stubs/flutter_langdetect
+13
View File
@@ -0,0 +1,13 @@
# Stuby nativních ML balíčků (fork tth)
`pubspec.yaml` je přes `dependency_overrides` podstrčí místo
`llamadart`, `flutter_onnxruntime` a `flutter_langdetect`. Mají jen to API,
které aplikace volá, a každé volání vyhodí `UnsupportedError`. Do APK se tak
nedostanou nativní knihovny llama.cpp / LiteRT-LM / ONNX Runtime (~200 MB)
a `lib/` zůstává shodné s upstreamem.
Důsledek: překlad zpráv a neuronový obrázkový kodek nefungují. Obě funkce jsou
v upstreamu ve výchozím stavu vypnuté a aplikace chybu zachytí a zaloguje.
Když upstream začne volat další symbol, build spadne na chybějícím
identifikátoru — doplň ho sem.
@@ -0,0 +1,4 @@
Future<void> initLangDetect() async {}
String detect(String text) =>
throw UnsupportedError('Language detection is not built in.');
+6
View File
@@ -0,0 +1,6 @@
name: flutter_langdetect
description: Stub without native code (meshcore-open tth fork).
version: 0.0.1
publish_to: none
environment:
sdk: ^3.9.2
@@ -0,0 +1,34 @@
Never _unsupported() =>
throw UnsupportedError('ONNX Runtime is not built in.');
class OnnxRuntime {
Future<OrtSession> createSession(String path, {Object? options}) async =>
_unsupported();
}
class OrtSession {
OrtSession._();
List<String> get inputNames => const <String>[];
List<String> get outputNames => const <String>[];
Future<Map<String, OrtValue>> run(
Map<String, OrtValue> inputs, {
Object? options,
}) async => _unsupported();
Future<void> close() async {}
}
class OrtValue {
OrtValue._();
static Future<OrtValue> fromList(Object data, List<int> shape) async =>
_unsupported();
List<int> get shape => const <int>[];
Future<List<dynamic>> asFlattenedList() async => _unsupported();
Future<void> dispose() async {}
}
+6
View File
@@ -0,0 +1,6 @@
name: flutter_onnxruntime
description: Stub without native code (meshcore-open tth fork).
version: 1.9.0
publish_to: none
environment:
sdk: ^3.9.2
+58
View File
@@ -0,0 +1,58 @@
Never _unsupported() => throw UnsupportedError('llama.cpp is not built in.');
enum GpuBackend { auto, cpu }
enum LlamaChatRole { system, user, assistant }
class ModelParams {
final int gpuLayers;
final GpuBackend preferredBackend;
const ModelParams({this.gpuLayers = 0, this.preferredBackend = GpuBackend.cpu});
}
class GenerationParams {
const GenerationParams({
int? maxTokens,
double? temp,
int? topK,
double? topP,
double? penalty,
bool? reusePromptPrefix,
});
}
class LlamaChatMessage {
LlamaChatMessage.fromText({required LlamaChatRole role, required String text});
}
class LlamaDelta {
String? get content => null;
}
class LlamaChoice {
LlamaDelta get delta => LlamaDelta();
}
class LlamaCompletionChunk {
List<LlamaChoice> get choices => const <LlamaChoice>[];
}
class LlamaBackend {}
class LlamaEngine {
LlamaEngine(LlamaBackend backend);
Future<void> loadModel(String path, {ModelParams? modelParams}) async =>
_unsupported();
Stream<LlamaCompletionChunk> create(
List<LlamaChatMessage> messages, {
GenerationParams? params,
bool? enableThinking,
String? sourceLangCode,
String? targetLangCode,
}) => _unsupported();
Future<void> dispose() async {}
}
+6
View File
@@ -0,0 +1,6 @@
name: llamadart
description: Stub without native code (meshcore-open tth fork).
version: 0.8.0
publish_to: none
environment:
sdk: ^3.9.2