4

I'm trying to run a command line using dart's Process.run

Here is my code

var result = await Process.run('axmldec', [ '-o','C:/test/output.xml'
      , 'C:/test/AndroidManifest.xml' ]);

thought the problem is the slash / so I also tried this

var result = await Process.run('axmldec', [ '-o','C:\\test\\output.xml'
      , 'C:\\test\\AndroidManifest.xml' ]);

Tried C: and D: drives with no luck. The error I get is

Command: axmldec -o D:/test/output.xml D:/test/AndroidManifest.xml
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:390:33)
#1      Process.start (dart:io-patch/process_patch.dart:36:20)
#2      _runNonInteractiveProcess (dart:io-patch/process_patch.dart:565:18)
#3      Process.run (dart:io-patch/process_patch.dart:47:12)
#4      Home._testUnzip (package:apk_analysis/main.dart:112:32)
#5      Home.build.<anonymous closure>.<anonymous closure> (package:apk_analysis/main.dart:60:25)
#6      _rootRunUnary (dart:async/zone.dart:1362:47)
#7      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#8      _FutureListener.handleValue (dart:async/future_impl.dart:152:18)
#9      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)
#10     Future._propagateToListeners (dart:async/future_impl.dart:733:32)
#11     Future._completeWithValue (dart:async/future_impl.dart:539:5)
#12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:254:13)
#13     FilePickerCross.importMultipleFromStorage (package:file_picker_cross/file_picker_cross.dart)
<asynchronous suspension>

And when I run the same command in the command line it works without problem.

2 Answers 2

1

I found the solution. The problem seemed to be path of the command itself "axmldec"

despite having that set in the environment variables, dart process did not recognize it. I used the full path and it worked

var result = Process.run('c:\\tool\\axmldec.exe', [ '-o','D:\\test\\output.xml'
      , 'D:\\test\\AndroidManifest.xml' ]);
Sign up to request clarification or add additional context in comments.

Comments

1

Marking runInShell to true may help when running commands (such as the flutter commnad).

Process.run(
  'flutter',
  [ 'create', 'example' ],
  runInShell: true,
  workingDirectory: directory,
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.