fischerscode / DockerFlutter

an automatically build Docker image containing the Flutter SDK
https://hub.docker.com/r/fischerscode/flutter
GNU General Public License v3.0
26 stars 14 forks source link

Connecting to a device (iPhone or Android) #18

Open AmirNaghibi opened 2 years ago

AmirNaghibi commented 2 years ago

Great project! I'm using your image and am able to create an app inside a flutter container.

Any tips on how to connect to a device? I have connected my iPad but after running flutter run I get an error:

No supported devices connected.

Is there any argument I need to pass when running a container? Currently I'm using the following command:

docker run --rm -it -h ubuntu -v $PWD:/software --name flutter -p 8080:8080 fischerscode/flutter /bin/bash
AmirNaghibi commented 2 years ago

This is what I see after running flutter doctor :

Screen Shot 2022-01-03 at 9 24 09 AM

I believe I need to install Android SDK and probably XCode for iPhone? 🤔

fischerscode commented 2 years ago

Never tried this since I am only using the image to build a flutter web application.

Connecting the device to the container could be done using --device.

I assume it's pretty hard to run on an iPhone since it would require xCode to build the application. Running on android might be possible by installing android studio.

fischerscode commented 2 years ago

Mainly for documenting progress

By doing the following it, it is possible to build an apk using this image. docker run --rm -ti fischerscode/flutter-sudo:stable

sudo apt-get update
sudo apt-get install -y libcanberra-gtk-module android-sdk software-properties-common
curl -o commandlinetools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip #link from https://developer.android.com/studio#command-tools
sudo mkdir -p /usr/lib/android-sdk/cmdline-tools
sudo unzip -d /usr/lib/android-sdk/cmdline-tools commandlinetools-linux.zip
sudo mv /usr/lib/android-sdk/cmdline-tools/cmdline-tools /usr/lib/android-sdk/cmdline-tools/latest

sudo /usr/lib/android-sdk/cmdline-tools/latest/bin/sdkmanager "platforms;android-29" "build-tools;32.0.0"
flutter create test
cd test
sudo /home/flutter/flutter-sdk/bin/flutter build apk