{"id":4302,"date":"2021-07-06T07:29:39","date_gmt":"2021-07-05T22:29:39","guid":{"rendered":"https:\/\/ecpplus.net\/weblog\/?p=4302"},"modified":"2021-07-14T16:29:37","modified_gmt":"2021-07-14T07:29:37","slug":"flutter-development-on-wsl2","status":"publish","type":"post","link":"https:\/\/ecpplus.net\/weblog\/flutter-development-on-wsl2\/","title":{"rendered":"WSL2 \u3067 Flutter \u958b\u767a (\u5b9f\u6a5f\u30c7\u30d0\u30c3\u30b0)"},"content":{"rendered":"<p>WSL2 \u3067 Flutter \u30a2\u30d7\u30ea\u3092\u958b\u767a\u3059\u308b\u6642\u306f\u3001\u73fe\u72b6\u3060\u3068 USB \u3067\u63a5\u7d9a\u3059\u308b\u3088\u308a\u304b\u306f Wi-Fi \u3067\u3064\u306a\u3050\u307b\u3046\u304c\u697d\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u74b0\u5883\u306f nvim \u3067\u4f5c\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<h2>Command line tools \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p>Android Studio \u306f\u5165\u308c\u306a\u3044\u306e\u3067\u3001 command line tools \u306e\u307f\u3092\u5165\u308c\u307e\u3059\u3002<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/developer.android.com\/studio#command-tools\" rel=\"noreferrer noopener\">Command line tools only<\/a> \u304b\u3089 Linux \u7248\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066 <code>unzip<\/code> \u3057\u307e\u3059\u3002<\/p>\n<p>\u4e2d\u306b\u306f<\/p>\n<ul>\n<li><code>cmdline-tools\/bin<\/code><\/li>\n<li><code>cmdline-tools\/lib<\/code><br \/>\n\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u4eca\u3001 ANDROID_SDK_ROOT \u3068\u3057\u3066 <code>~\/.android<\/code> \u3092\u4f7f\u3046\u3088\u3046\u306b\u3057\u3066\u8a71\u3092\u9032\u3081\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sh\">\u276f mkdir ~\/.android\n\u276f mv cmdline-tools ~\/.android\n\u276f cd ~\/.android\/cmdline-tools\n\u276f mkdir latest # \u968e\u5c64\u30921\u500b\u6398\u308b\u5fc5\u8981\u304c\u3042\u308b\n\u276f mv bin latest\/\n\u276f mv lib latest\/<\/code><\/pre>\n<p>\u968e\u5c64\u69cb\u9020\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>cmdline-tools\n\u251c\u2500\u2500 latest\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 bin\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 apkanalyzer\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 avdmanager\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 lint\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 retrace\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u251c\u2500\u2500 screenshot2\n\u2502\u00a0\u00a0 \u2502\u00a0\u00a0 \u2514\u2500\u2500 sdkmanager\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 lib\n...<\/code><\/pre>\n<h3>zshrc \u3092\u8a2d\u5b9a<\/h3>\n<p>\u4e0b\u8a18\u306e\u3088\u3046\u306b PATH \u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sh\">export ANDROID_SDK_ROOT=$HOME\/.android\nexport PATH=$ANDROID_SDK_ROOT\/cmdline-tools\/tools:$PATH\nexport PATH=$ANDROID_SDK_ROOT\/cmdline-tools\/tools\/bin:$PATH\nexport PATH=$ANDROID_SDK_ROOT\/cmdline-tools\/tools\/lib:$PATH\nexport PATH=$ANDROID_SDK_ROOT\/platform-tools:$PATH\nexport PATH=$ANDROID_SDK_ROOT\/emulator:$PATH<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u74b0\u5883\u5909\u6570\u3092\u9069\u7528\u3057\u305f\u72b6\u614b\u306b\u3057\u3066\u6b21\u3078\u9032\u307f\u307e\u3059\u3002<\/p>\n<h2>adb \u3092\u8a2d\u5b9a<\/h2>\n<a target=\"_blank\" href=\"https:\/\/developer.android.com\/studio\/command-line\/adb#connect-to-a-device-over-wi-fi-android-11+\" rel=\"noreferrer noopener\">Connect to a device over Wi-Fi (Android 11+)<\/a>\n<p>\u306e\u901a\u308a\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>Android \u306e Developer settings \u304b\u3089 <code>Wireless debugging<\/code> \u3092 ON \u306b\u3057\u307e\u3059\u3002\u2191\u306e\u30b5\u30a4\u30c8\u3060\u3068\u3001ON \u306b\u3057\u305f\u6642\u306e\u30c0\u30a4\u30a2\u30ed\u30b0\u306b\u6cbf\u3063\u3066\u8a2d\u5b9a\u3059\u308b\u3068\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u304c\u3001\u9593\u9055\u3063\u3066\u6d88\u3057\u3061\u3083\u3063\u305f\u6642\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><code>Wireless debugging<\/code> \u3068\u66f8\u3044\u3066\u3042\u308b\u6587\u5b57\u306e\u4e0a\u3092\u30bf\u30c3\u30d7\u3059\u308b\u3068\u3001\u4e0b\u306e\u968e\u5c64\u3078\u9032\u307f\u307e\u3059\u3002 <code>Pair device with paring code<\/code> \u3092\u30bf\u30c3\u30d7\u3059\u308b\u3068\u3001 <code>Pair with device<\/code> \u306e Dialog \u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067 <code>IP address and port<\/code> \u3068\u3044\u3046\u8868\u793a\u304c\u3042\u308b\u306e\u3067\u3001WSL2 \u4e0a\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089<\/p>\n<pre><code class=\"language-sh\">\u276f adb pair 192.168.1.123:34567<\/code><\/pre>\n<p>\u306e\u3088\u3046\u306b\u3057\u3066\u63a5\u7d9a\u3057\u3001Android \u753b\u9762\u4e0a\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u308b <code>Wi-Fi paring code<\/code> \u3092\u5165\u529b\u3057\u307e\u3059\u3002\u6b63\u3057\u304f\u5165\u529b\u3059\u308b\u3068\u6210\u529f\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u5f8c\u306f\u3001<strong>Wireless debugging<\/strong> \u306e\u753b\u9762\u306b\u623b\u308a\u3001\u4e0a\u306e\u65b9\u306b\u51fa\u3066\u3044\u308b <code>IP address and port<\/code> \u3092\u78ba\u8a8d\u3057\u3001 adp connect \u3057\u307e\u3059\u3002\u3053\u306e port \u306f paring \u306e\u969b\u306e port \u3068\u306f\u7570\u306a\u308b\u306e\u3067\u6ce8\u610f\u3002<\/p>\n<pre><code class=\"language-sh\">\u276f adb connect 192.168.1.123:35555<\/code><\/pre>\n<p>\u63a5\u7d9a\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sh\">\u276f adb devices\nList of devices attached\n192.168.1.123:35555      device<\/code><\/pre>\n<h2>Flutter \u3092\u8d77\u52d5<\/h2>\n<pre><code class=\"language-sh\">\u276f flutter doctor\nDoctor summary (to see all details, run flutter doctor -v):\n[\u2713] Flutter (Channel stable, 2.2.3, on Linux, locale en_US.UTF-8)\n[\u2713] Android toolchain - develop for Android devices (Android SDK version 30.0.3)\n[\u2713] Chrome - develop for the web\n[!] Android Studio (not installed)\n[\u2713] Connected device (2 available)\n\n! Doctor found issues in 1 category.<\/code><\/pre>\n<p>Android Studio \u306f\u4eca\u56de\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u898b\u3064\u304b\u3089\u306a\u304f\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre><code>\u276f flutter devices\n2 connected devices:\n\nPixel 4 (mobile) \u2022 192.168.1.123:35555 \u2022 android-arm64  \u2022 Android 11 (API 30)\nChrome (web)     \u2022 chrome             \u2022 web-javascript \u2022 Google Chrome 91.0.4472.114<\/code><\/pre>\n<p>Flutter \u304b\u3089\u3082 device \u304c\u898b\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sh\">\u276f flutter run -d 192.168.1.123:35555<\/code><\/pre>\n<p>\u306a\u304a\u3001devices \u3067 Web \u3082\u898b\u3048\u3066\u3044\u307e\u3059\u304c\u3001 <code>-d chrome<\/code> \u3068\u3057\u3066\u3082 WSL\u5185\u3067\u306f\u7acb\u3061\u4e0a\u304c\u3089\u306a\u3044\u305f\u3081\u3001Web\u7248\u3092\u8d77\u52d5\u3057\u305f\u3044\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3057\u3066 Web Server \u3092\u7acb\u3061\u4e0a\u3052\u308c\u3070\u3001Windows \u5074\u306e\u30d6\u30e9\u30a6\u30b6\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sh\">\u276f flutter run -d web-server\nLaunching lib\/main.dart on Web Server in debug mode...\nWaiting for connection from debug service on Web Server...         16.2s\nlib\/main.dart is being served at http:\/\/localhost:44711\nThe web-server device requires the Dart Debug Chrome extension for debugging. Consider using the Chrome or Edge devices for an improved development workflow.\n\n\ud83d\udd25  To hot restart changes while running, press &quot;r&quot; or &quot;R&quot;.\nFor a more detailed help message, press &quot;h&quot;. To quit, press &quot;q&quot;.<\/code><\/pre>\n<p>\u6a19\u6e96\u51fa\u529b\u306bURL\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u3053\u306e\u5834\u5408\u3060\u3068 <code><a href=\"http:\/\/localhost:44711\">http:\/\/localhost:44711<\/a><\/code> \u3092\u958b\u3051\u3070 Web \u7248\u304c\u898b\u3089\u308c\u307e\u3059\u3002<\/p>\n<hr \/>\n<p>USB\u3067\u3064\u306a\u3050\u306e\u306f\u7d50\u69cb\u624b\u9593\u304c\u304b\u304b\u308a\u305d\u3046\u3067\u3057\u305f\u304c\u3001Wi-Fi \u63a5\u7d9a\u3067\u3042\u308c\u3070\u3059\u3050\u306b\u8a2d\u5b9a\u304c\u51fa\u6765\u307e\u3057\u305f\ud83d\ude0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WSL2 \u3067 Flutter \u30a2\u30d7\u30ea\u3092\u958b\u767a\u3059\u308b\u6642\u306f\u3001\u73fe\u72b6\u3060\u3068 USB \u3067\u63a5\u7d9a\u3059\u308b\u3088\u308a\u304b\u306f Wi-Fi \u3067\u3064\u306a\u3050\u307b\u3046\u304c\u697d\u305d\u3046\u3067\u3059\u3002 \u74b0\u5883\u306f nvim \u3067\u4f5c\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002 Command line tools \u3092\u30a4\u30f3\u30b9\u30c8\u30fc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4236,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[67,68,13],"class_list":["post-4302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","tag-android","tag-flutter","tag-windows"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/comments?post=4302"}],"version-history":[{"count":4,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4302\/revisions"}],"predecessor-version":[{"id":4336,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/posts\/4302\/revisions\/4336"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media\/4236"}],"wp:attachment":[{"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/media?parent=4302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/categories?post=4302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ecpplus.net\/weblog\/wp-json\/wp\/v2\/tags?post=4302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}