I am fairly new to the dart and flutter. I'd like to make an installer for an android app running on windows by flutter language. To execute adb commands I am using Process.run()
with adb platform-tools path which is currently stored on my desktop. I'd like to have this folder stored inside my flutter .exe or somewhere near finalapp.exe when I'll build it with the command flutter build windows
so the windows app can still use and access platform-tools without changing the path to it. (I am imagining to work like this: I will create a .exe app, then I will open it on another computer with clean windows install and the app [stored inside the platform-tools] could still be installed by platform-tools stored inside the same .exe) How can I achieve it, please?
Here is my code:
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'installation_and_permissions.dart' as installer;
var stdoutCommand = "", stderrCommand = "", deviceName = "";
Future<void> main() async {
await Process.run(
'adb',
['devices'],
workingDirectory: "assets\\platform-tools",
runInShell: true,
).then((ProcessResult res) {
stdoutCommand = res.stdout;
deviceName = stdoutCommand.substring(26, 34);
stderrCommand = res.stderr;
print(res.stdout);
print(res.stderr);
});
//await installer.installApp();
//await installer.grantPermissions();
runApp(const MyApp());
}
Right now I have my assets (platform-tools and apk I want to install) stored in folder assets and in pubspecs.yaml assets are added:
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets\platform-tools
- assets\platform-tools\app-release-v3.1.01.apk
I googled a lot but I am not a native English speaker and I was unable to find a solution.
Had the same issue. Tried so many. The solution is to add your work directory(as in the example) in the code of your class and to add needed adb files to assets in pubspecs.yaml.
Directory.current = 'data/flutter_assets';
//pubspecs.yaml
assets:
- adb.exe
- AdbWinApi.dll
- AdbWinUsbApi.dll
- install.apk
Then make release build with the command:
flutter build windows
Go to your project directory "build\windows\runner\Release" and make sure that your assets files present in "data\flutter_assets". Run your app.exe