`flutter config --android-sdk /opt/android-sdk/` not working on arch linux how can i configure?

Viewed 604

I am installing flutter without android-studio on arch linux with this guide: https://ksrk.medium.com/install-flutter-without-android-studio-on-ubuntu-a14a66a88f9f

and also this: https://dev.to/awais/configure-flutter-development-environment-on-manjaro-arch-linux-4a0a

$ flutter --version
Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 18116933e7 (19 hours ago) • 2021-10-15 10:46:35 -0700
Engine • revision d3ea636dc5
Tools • Dart 2.14.4

I also installed Android SDK and configured PATH variables in my .zshrc file as you can see below.

# .zshrc

export JAVA_HOME='/usr/lib/jvm/java-8-openjdk'
export PATH=$JAVA_HOME/bin:$PATH 
export ANDROID_SDK_ROOT='/opt/android-sdk'
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/
export CHROME_EXECUTABLE=/usr/bin/brave

Still, it gives me an error in flutter doctor so I have tried other commands also to configure it.

$ flutter config --android-sdk /opt/android-sdk/

still, it gives me an error in flutter doctor.

[✓] Flutter (Channel stable, 2.5.3, on Arch Linux 5.14.7-arch1-1, locale en_US.UTF-8)
    • Flutter version 2.5.3 at /opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (19 hours ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✗] Android toolchain - develop for Android devices
    • Android SDK at /opt/android-sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

! Doctor found issues in 2 categories.

As you can also see it's detected Android SDK at /opt/android-sdk still it's giving me an error in Android toolchain.

I also can't set up a license without it.

$ flutter doctor --android-licenses
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to
resolve this.

I have sdkmanager in my PATH variable and also working still gives an error

$ which sdkmanager
/opt/android-sdk/tools/bin/sdkmanager

I don't want to install android studio because I don't want to run it in an emulator I want to run on my mobile directly with hot reload so I don't have to install android on my os.

1 Answers

I am sorry for didn't read the error properly if you see there is clearly written that cmdline-tools component is missing.

So I have searched for in aur repository of arch and found one package.

$ yay -S android-sdk-cmdline-tools-latest

After installing this package it worked fine.

Related