Skip to content

dart .\setup.dart android在构建flutter_distributor的时候出现错误 #1080

Open
@flying-forever

Description

@flying-forever

起初提示有非utf8的字符,于是我要try-catch把两行解码的代码包裹了一下,然后出现另一个错误,不清楚是发生了什么问题😭:

flutter_distributor package --skip-clean --platform android --targets apk --flutter-build-args=verbose --flutter-build-args split-per-abi --build-target-platform android-arm,android-arm64,android-x64 --build-dart-define=APP_ENV=pre
run android
'flutter_distributor' �����ڲ����ⲿ���Ҳ���ǿ����еij���
�����������
Unhandled exception:
android error
#0      Build.exec (file:///C:/Users/ThinkPad/Desktop/FlClash/setup.dart:213:40)
<asynchronous suspension>
#1      BuildCommand._buildDistributor (file:///C:/Users/ThinkPad/Desktop/FlClash/setup.dart:454:5)
<asynchronous suspension>
static Future<void> exec(
    List<String> executable, {
    String? name,
    Map<String, String>? environment,
    String? workingDirectory,
    bool runInShell = true,
  }) async {
    if (name != null) print("run $name");
    final process = await Process.start(
      executable[0],
      executable.sublist(1),
      environment: environment,
      workingDirectory: workingDirectory,
      runInShell: runInShell,
    );

    // process.stdout.listen((data) {
    //   print(utf8.decode(data));
    // });
    // process.stderr.listen((data) {
    //   print(utf8.decode(data));
    // });

    process.stdout.listen((data) {
      try {
        print(utf8.decode(data)); // 允许非UTF8数据
      } catch (e) {
        print('[Binary data skipped]'); // 或转为16进制显示
        print(data.map((b) => b.toRadixString(16)).join(' '));
      }
    });
    process.stderr.listen((data) {
      try {
        print(utf8.decode(data)); // 允许非UTF8数据
      } catch (e) {
        print('[Binary data skipped]'); // 或转为16进制显示
        print(data.map((b) => b.toRadixString(16)).join(' '));
      }
    });

    final exitCode = await process.exitCode;
    if (exitCode != 0 && name != null) throw "$name error";
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions