LoginSignup
0
1

More than 3 years have passed since last update.

【Flutter】Ubuntu20.04環境構築

Posted at

動作環境

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

1.Flutterをインストールしてパスを通す

Linux install-Flutter(公式ドキュメント)

ホームディレクトリに「dev」ディレクトリを作ってcdで移動。

$ mkdir dev
$ cd dev

「dev」ディレクトリにflutterをcloneする。

$ git clone https://github.com/flutter/flutter.git

現在のパスを確認。

$ pwd
/home/haru/dev

export PATH="$PATH:pwd/flutter/bin"

公式ドキュメントではこのようにパスを通すよう説明されている。
pwdコマンドで帰ってきたパスを「pwd」の部分にコピペ。

例:export PATH="$PATH:/home/haru/dev/flutter/bin"

これをbashrcに追加する。今回エディタはVScodeを使用。

$ code ~/.bashrc
(VScodeで.bashrcを開き『export PATH="$PATH:/home/haru/dev/flutter/bin"』を貼り付ける)
$ source ~/.bashrc

flutter doctorで確認。

$ flutter doctor

Screenshot from 2020-09-14 20-46-40.png

上のような画面が出るとパスを通すまでは完了。

2.AndroidStudioをインストール

『Ubuntu Software』でAndroidStudioをインストール
Screenshot from 2020-09-14 20-47-35.png

インストールして実行する。
androidStudio.jpg

画面下のConfigure→Pluginsへ進む。
FlutterPlugin.jpg
Flutterプラグインをインストール。
pulgin.png

プラグインをインストール後『Start new Flutter project』から新しいプロジェクトを始めることができる。
addflutter.jpg

一旦AndroidStudioを終了し以下のコマンドでAndroidのライセンスも同意しておく。数回同意を求められるので全て『y』で答える。

$ flutter doctor --android-licenses
Warning: File /home/haru/.android/repositories.cfg could not be loaded.         
6 of 6 SDK package licenses not accepted. 100% Computing updates...             
Review licenses that have not been accepted (y/N)? y

3.Androidエミュレータを導入

AndroidStudioを起動後画面下のConfigure→AVDManagerへ進む。
AVD.jpg
CreateVirtualDevice
device01.jpg

今回の環境ではPlayStoreが入っているものを選択するとエミュレータ起動時にフリーズしてしまったため、PlayStoreなしのPixel 2XLを使用。
device02.jpg
SystemImageはQ(API29)を使用。
Screenshot from 2020-09-14 21-27-39.png

Graphicsの項目を『Software-GLES2.0』に変更。
*ここの変更をしていないとエミュレータ起動時にフリーズ。
Screenshot from 2020-09-14 21-28-18.jpg
無事に起動しました!
Screenshot from 2020-09-14 21-30-53.png

最後にflutter doctorで確認。

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.20.3, on Linux, locale ja_JP.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)

• No issues found!
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1