NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.42k stars 12.92k forks source link

Flutter can't detect built-in Android Studio JDK (JBR) and connected device #309467

Open Anifyuli opened 1 month ago

Anifyuli commented 1 month ago

Describe the bug

Hello anyone, I want to report this Flutter bug. It can't detect JBR flawlessly and connected device too on flutter doctor -v.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install Flutter with write to configuration.nix / Home Manager
  2. Run flutter doctor -v
  3. This bug is appear

Expected behavior

Flutter can show it properly & not showing issues

Screenshots

Its too long text, so I show it outputs.

$ flutter doctor -v
[✓] Flutter (Channel stable, 3.19.4, on NixOS 23.11 (Tapir) 6.1.90, locale en_US.UTF-8)
    • Flutter version 3.19.4 on channel stable at /nix/store/wiwqsx1cl7p5hqnxjdfj83fxiwav6xbj-flutter-wrapped-3.19.4-sdk-links
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision nixpkgs000 (), 1970-01-01 00:00:00
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/anifyuli/.android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /nix/store/1i7rvym5q0sgxcbxkjxpkdwyh3fmhr86-android-sdk
    • Java binary at: /run/current-system/sw/bin/java
    • Java version OpenJDK Runtime Environment (build 19.0.2+7-nixos)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = google-chrome-stable

[✓] Linux toolchain - develop for Linux desktop
    • clang version 16.0.6
    • cmake version 3.27.7
    • ninja version 1.11.1
    • pkg-config version 0.29.2

[!] Android Studio (version 2023.2)
    • Android Studio at /nix/store/pc4fn8zl4336bdlagji24hpn8qs4n1c2-android-studio-stable-2023.2.1.25-unwrapped
    • Flutter plugin version 79.0.1
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Failed to run Java: ProcessException: No such file or directory
        Command: /nix/store/pc4fn8zl4336bdlagji24hpn8qs4n1c2-android-studio-stable-2023.2.1.25-unwrapped/jbr/bin/java -version
    ✗ Unable to determine bundled Java version.
    • Try updating or re-installing Android Studio.

[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this
      issue at https://github.com/flutter/flutter/issues.
    ✗ Error: Unable to run "adb", check your Android SDK installation and ANDROID_HOME environment variable:
      /home/anifyuli/.android/sdk/platform-tools/adb
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      AndroidDevices.pollingGetDevices (package:flutter_tools/src/android/android_device_discovery.dart:75:7)
      <asynchronous suspension>
      #2      PollingDeviceDiscovery._populateDevices (package:flutter_tools/src/device.dart:549:36)
      <asynchronous suspension>
      #3      Future.wait.<anonymous closure> (dart:async/future.dart:518:21)
      <asynchronous suspension>
      #4      DeviceManager.refreshAllDevices (package:flutter_tools/src/device.dart:216:40)
      <asynchronous suspension>
      #5      DeviceValidator.validate (package:flutter_tools/src/doctor.dart:738:34)
      <asynchronous suspension>
      #6      Future.any.onValue (dart:async/future.dart:608:5)
      <asynchronous suspension>

[✓] Network resources
    • All expected network resources are available.

Additional context

I wish it can fixed, I haven't idea to fix this.

Notify maintainers

@babariviere @ericdallo @FlafyDev @hacker1024 @NixOS/flutter

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

anifyuli@ThinkPad-X280:~  
$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.90, NixOS, 23.11 (Tapir), 23.11.6827.383ffe076d9b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(root): `"android-nixpkgs, home-manager-23.11.tar.gz, nixos-23.11, nixos-hardware, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

RemcoSchrijver commented 1 month ago

Can you provide a flake or nix file that allows for replicating your environment, because using my dev environments I cannot replicate this issue.

[✓] Flutter (Channel stable, 3.19.4, on NixOS 24.05 (Uakari) 6.6.24, locale en_US.UTF-8)
    • Flutter version 3.19.4 on channel stable at /nix/store/wiwqsx1cl7p5hqnxjdfj83fxiwav6xbj-flutter-wrapped-3.19.4-sdk-links
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision nixpkgs000 (), 1970-01-01 00:00:00
    • Engine revision a5c24f538d
    • Dart version 3.3.2
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /nix/store/b9998grlb835879syniymh5g0v7h3c2y-android-sdk-env/share/android-sdk
    • Platform android-33, build-tools 33.0.2
    • ANDROID_HOME = /nix/store/b9998grlb835879syniymh5g0v7h3c2y-android-sdk-env/share/android-sdk
    • ANDROID_SDK_ROOT = /nix/store/b9998grlb835879syniymh5g0v7h3c2y-android-sdk-env/share/android-sdk
    • Java binary at: /nix/store/wllh79pkkw8l8b06jrv63y9rgvnvndhm-android-studio-stable-2023.2.1.24-unwrapped/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /home/remco/.nix-profile/bin/chromium

[✓] Linux toolchain - develop for Linux desktop
    • clang version 17.0.6
    • cmake version 3.29.2
    • ninja version 1.11.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2023.1)
    • Android Studio at /nix/store/51qj1qsns3arj8lj3izngkb7vxk1zcnw-android-studio-stable-2023.1.1.26-unwrapped
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] Android Studio (version 2023.2)
    • Android Studio at /nix/store/wllh79pkkw8l8b06jrv63y9rgvnvndhm-android-studio-stable-2023.2.1.24-unwrapped
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.3)
    • IntelliJ at /nix/store/zqmd2kcmk2pzz0z5lj1n37fplciq7p74-idea-ultimate-2023.3.1/idea-ultimate
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • NixOS 24.05 (Uakari) 6.6.24
    • Chrome (web)    • chrome • web-javascript • Chromium 123.0.6312.86

[✓] Network resources
    • All expected network resources are available.

• No issues found!

With nix-info:

 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.24, NixOS, 24.05 (Uakari), 24.05.20240403.fd281bd`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos-23.05, nixos-hardware"`
 - nixpkgs: `/nix/store/n2g5cqwv8qf5p6vjxny6pg3blbdij12k-source`
Anifyuli commented 1 month ago

Wow, how can you do that? I'm still confused because of these silly problems

RemcoSchrijver commented 1 month ago

I use nix-direnv for activating my dev environments, and I use a flake to load flutter etc.

However looking more closely at your problem, did you ever start up android-studio, and did you initialize your jdk? Because it seems that android studio just did not load this yet.

Anifyuli commented 1 month ago

Ok, thanks for your suggestions. I think my Android Studio can detect it JBR because it not report anything about failed loading or something else

RemcoSchrijver commented 1 month ago

Ok, thanks for your suggestions. I think my Android Studio can detect it JBR because it not report anything about failed loading or something else

Alright then does the jbr/bin/ folder exist? And just Java missing or is the whole folder missing?