Environment
Package: android_libcpp_shared v0.2.0
OS: Windows 10/11 (Chinese / Japanese / Korean locale)
Dart SDK: ^3.12.0
Unhandled exception:
FormatException: Missing extension byte (at offset 1)
#0 _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1964:7)
#1 _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:313:28)
...
#4 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:115:24)
- Root cause
lib/src/process.dart lines 29–32 — runProcess() hardcodes utf8.decoder:
final stdoutFuture = process.stdout
.transform(utf8.decoder) // ← the problem
.transform(const LineSplitter())
.forEach(stdout.writeln);
On non-English Windows (e.g. Chinese/Japanese/Korean locale), where.exe outputs error messages in the system code page (e.g. CP936 for Chinese), not UTF-8:
C:\> where ndk-build.cmd
信息: 用提供的模式无法找到文件。 ← CP936 (GBK) encoded
For example, the Chinese character 信 is encoded as 0xD0 0xC5 in GBK. utf8.decoder sees 0xD0 as a 2-byte UTF-8 lead byte and expects the next byte in range 0x80–0xBF. But 0xC5 is not in that range → FormatException is thrown.
On English Windows the output is pure ASCII (INFO: Could not find files...) so it never triggers.
Reproduction
1.Use a non-English Windows system (Chinese / Japanese / Korean locale)
2.Do NOT have ndk-build.cmd in PATH
3.Build any Flutter project that depends on android_libcpp_shared
where ndk-build.cmd
# Outputs localized error → Dart process crashes with FormatException
Suggested fix
Use platform-appropriate decoder in process.dart:
final encoding = Platform.isWindows ? systemEncoding : utf8;
final stdoutFuture = process.stdout
.transform(encoding.decoder)
.transform(const LineSplitter())
.forEach(stdout.writeln);
// same for stderr
Or wrap the which() call with a try-catch for non-zero exit codes.
Environment
Package: android_libcpp_shared v0.2.0
OS: Windows 10/11 (Chinese / Japanese / Korean locale)
Dart SDK: ^3.12.0
lib/src/process.dart lines 29–32 — runProcess() hardcodes utf8.decoder:
On non-English Windows (e.g. Chinese/Japanese/Korean locale), where.exe outputs error messages in the system code page (e.g. CP936 for Chinese), not UTF-8:
For example, the Chinese character 信 is encoded as 0xD0 0xC5 in GBK. utf8.decoder sees 0xD0 as a 2-byte UTF-8 lead byte and expects the next byte in range 0x80–0xBF. But 0xC5 is not in that range → FormatException is thrown.
On English Windows the output is pure ASCII (INFO: Could not find files...) so it never triggers.
Reproduction
1.Use a non-English Windows system (Chinese / Japanese / Korean locale)
2.Do NOT have ndk-build.cmd in PATH
3.Build any Flutter project that depends on android_libcpp_shared
where ndk-build.cmd # Outputs localized error → Dart process crashes with FormatExceptionSuggested fix
Use platform-appropriate decoder in process.dart:
Or wrap the which() call with a try-catch for non-zero exit codes.