Agar Intellij atau Android Studio dapat mengenali perangkat Android di proyek Flutter

Dua hari terakhir kembali googling tentang Flutter dan kawan-kawannya. Kali ini juga belajar di codelabsnya agar supaya~~~.. Selama coba-coba Flutter, ada satu hal yang bikin ribet, setiap coba menjalankan aplikasi (run) harus selalu lewat terminal. Padahal di tutorialnya cukup klik tombol segitiga hijau saja. Ini kenapa?

Unable list devices

Unable list devices



Selain tidak bisa membaca emulator maupun ponsel yang sudah terhubung dengan adb (bisa dilihat dari perintah adb devices), perintah flutter doctor dari menu Tools > Flutter > Flutter Doctor pun menghasilkan keluaran berbeda dibandingkan menjalankan flutter doctor langsung lewat terminal. Ini keluaran dari menu di Intellij maupun Android Studio:

/home/hahn/program/flutter/bin/flutter --no-color doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.3.5, on Linux, locale id_ID.UTF-8)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.io/setup/#android-setup for detailed instructions).
      If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.
[✓] Android Studio (version 3.1)
[!] IntelliJ IDEA Ultimate Edition (version 2017.2)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1)
[!] VS Code (version 1.22.2)
[!] Connected devices
    ! No devices available

! Doctor found issues in 4 categories.
Process finished with exit code 0

Sementara hasil perintah di terminal:

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.3.5, on Linux, locale id_ID.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] Android Studio (version 3.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1)
[!] VS Code (version 1.22.2)
[✓] Connected devices (1 available)

! Doctor found issues in 1 category.

Dari hasil googling, ternyata masalahnya bukan di Intellij maupun Android Studio, tapi di konfigurasi Flutter sendiri. Dari komentar isu di sini, ternyata kita tinggal menjalankan perintah flutter config –anu. Begini perintahnya:

$ flutter config --android-sdk /path/to/android/sdk
$ flutter config --android-studio-dir /path/to/android/studio

Setelah itu, restart dulu Intellij atau Android Studionya. Jika tidak ada masalah lain, seharusnya mereka sudah bisa membaca perangkat ponsel maupun emulator yang sudah terhubung. Proficiat!

Debug di Xiaomi Redmi Note

Tapi masih ada masalah lain sih. Menu Logcat belum bisa mendeteksi keberadaan perangkat ini. Tapi ya sudahlah, yang penting bisa debug dulu, kan?

tidak terdeteksi sama logcat

Sekali lagi, proficiat!

Ada komentar?

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: