babariviere / flutter-nix-hello-world

Demonstration on how to use flutter with Nix
52 stars 10 forks source link

Instructions for starting an emulator? #2

Open jmackie opened 4 years ago

jmackie commented 4 years ago

flutter build apk is working for me on NixOS :ok_hand:

Now I'd like to flutter run on an emulator. So still with virtually no understanding on Android I tried:

# emulate.nix

{ pkgs ? import <nixpkgs> { config = { android_sdk.accept_license = true; }; }}:
pkgs.androidenv.emulateApp {
  name = "emulate-MyAndroidApp";
  platformVersion = "28";
  abiVersion = "x86_64"; # armeabi-v7a, mips, x86
  systemImageType = "google_apis_playstore";
}

(Side note: might be worth adding instructions for accepting the license to the README?)

$ nix-build emulate.nix
$ ./result/bin/run-test-emulator

But that crashes with

Looking for a free TCP port in range 5554-5584
We have a free TCP port: 5554
Available Android targets:
----------
id: 1 or "android-28"
     Name: Android 9
     Type: Platform
     API level: 28
     Revision: 6
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : google_apis_playstore/x86_64
Android 9 is a basic Android platform.
Do you wish to create a custom hardware profile [no]Created AVD 'device' based on Android 9, Google apis playstore Intel Atom (x86_64) processor,
with the following hardware config:
hw.lcd.density=240
hw.ramSize=512
vm.heapSize=48
Waiting until the emulator has booted the device and the package manager is ready...
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [/nix/store/kc53pal1a28qzm3vv8ia8s8kzy7yr2nk-androidsdk/libexec/android-sdk]!
babariviere commented 4 years ago

Nice suggestion ! I will try to do it, I must admit that I have never tried to use an emulator with flutter on Nix.

jmackie commented 4 years ago

Ahh that's interesting - I assumed that was the normal workflow but I have no idea. What does your workflow and without an emulator?

-------- Original Message -------- On 11 Jan 2020, 10:45, Bastien Rivière wrote:

Nice suggestion ! I will try to do it, I must admit that I have never tried to use an emulator with flutter on Nix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

babariviere commented 4 years ago

I run my projects on my Android phone + I compile for the web too. So I don't need any emulator for now, but I will when I will have to test for different display size

babariviere commented 4 years ago

So as an update to this issue. I have tried to setup an emulator but I can't fully reproduce it with nix (I would like to include the emulator in the nix file instead of downloading it via android studio). If you have any guidelines, I will happily hear them :smile:

zh4ngx commented 7 months ago

@jmackie How did you get flutter build apk working on NixOS? Any changes to the flake or configuration.nix?