Home > Enterprise >  How to solve Flutter debuging problems ? (Unix, ubuntu)
How to solve Flutter debuging problems ? (Unix, ubuntu)

Time:10-24

I am using visual studio and i have installed flutter and dart on it, when i test debugging I got errors after long time. I am using Ubuntu:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:    20.04
Codename:   focal

When I run flutter doctor i got:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.1, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2020.3)
[✓] Connected device (1 available)

! Doctor found issues in 2 categories.

And the errors i got:

Installing Android SDK Platform 30 in /home/mea/Android/Sdk/platforms/android-30
"Install Android SDK Platform 30 (revision: 3)" complete.
"Install Android SDK Platform 30 (revision: 3)" finished.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not download x86_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.jar (io.flutter:x86_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718)
      > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.jar'.
         > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.jar'.
            > Connect to storage.googleapis.com:443 [storage.googleapis.com/142.250.200.112, storage.googleapis.com/172.217.17.16, storage.googleapis.com/142.250.201.80, storage.googleapis.com/172.217.168.176, storage.googleapis.com/142.250.200.80, storage.googleapis.com/216.58.215.176, storage.googleapis.com/216.58.215.144, storage.googleapis.com/142.250.184.16, storage.googleapis.com/216.58.209.80, storage.googleapis.com/142.250.185.16, storage.googleapis.com/142.250.200.144, storage.googleapis.com/142.250.184.176, storage.googleapis.com/2a00:1450:4003:80a:0:0:0:2010, storage.googleapis.com/2a00:1450:4003:80c:0:0:0:2010, storage.googleapis.com/2a00:1450:4003:802:0:0:0:2010, storage.googleapis.com/2a00:1450:4003:801:0:0:0:2010] failed: Network is unreachable (connect failed)
   > Could not download x86_64_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.jar (io.flutter:x86_64_debug:1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718)
      > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_64_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.jar'.
         > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718/x86_64_debug-1.0.0-0fdb562ac8068ce3dda6b69aca3f355f4d1d2718.jar'.
            > Connect to storage.googleapis.com:443 [storage.googleapis.com/142.250.200.112, storage.googleapis.com/172.217.17.16, storage.googleapis.com/142.250.201.80, storage.googleapis.com/172.217.168.176, storage.googleapis.com/142.250.200.80, storage.googleapis.com/216.58.215.176, storage.googleapis.com/216.58.215.144, storage.googleapis.com/142.250.184.16, storage.googleapis.com/216.58.209.80, storage.googleapis.com/142.250.185.16, storage.googleapis.com/142.250.200.144, storage.googleapis.com/142.250.184.176, storage.googleapis.com/2a00:1450:4003:80a:0:0:0:2010, storage.googleapis.com/2a00:1450:4003:80c:0:0:0:2010, storage.googleapis.com/2a00:1450:4003:802:0:0:0:2010, storage.googleapis.com/2a00:1450:4003:801:0:0:0:2010] failed: Network is unreachable (connect failed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 9m 30s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

And i accepted the license and it doesn’t work.

CodePudding user response:

Run this in terminal and accept all the options by pressing y several times.

flutter doctor --android-licenses

CodePudding user response:

I found solution (for ubuntu 20.04 users who uses java11)

java11 doesn't work fine with android development so I have uninstall it by remove java repo (Since Java 11 has removed JavaEE) read about it here: JDK 11: End of the road for Java EE modules

uninstall java 11

if not sure where you have installed it run find command:

sudo find / -type d -name jdk-17

remove it :

sudo rm -r jdk-17/

then remove java and javac from /usr/bin/ directory

PC-NAME1:/usr/bin$ sudo rm java javac

install java 8

run snap command :

sudo apt install -y openjdk-8-jdk

if java -version didn't work and outputs was looks like :

$java --version

Command 'java' not found, but can be installed with:

sudo apt install default-jre              # version 2:1.11-72, or
sudo apt install openjdk-11-jre-headless  # version 11.0.11 9-0ubuntu2~20.04
sudo apt install openjdk-16-jre-headless  # version 16.0.1 9-1~20.04
sudo apt install openjdk-8-jre-headless   # version 8u292-b10-0ubuntu1~20.04
sudo apt install openjdk-13-jre-headless  # version 13.0.7 5-0ubuntu1~20.04
sudo apt install openjdk-17-jre-headless  # version 17 35-1~20.04

in this case you have to switch jdk by running java config command:

sudo update-alternatives --config java

[sudo] password for mea: 
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

and make same thing for javac by changing every java by javac.

then install cmdline-tools :

install command line tools

run /home/machine_name/Android/Sdk/tools/bin/sdkmanager --install "cmdline-tools;latest"

accept android license

and finally run that know command to accept license :

flutter doctor --android-licenses

press y till end.

  • Related