Closed18

flutter 環境構築

tkttkt
$ brew install flutter
$ flutter doctor

で基本は大丈夫そう

tkttkt
> flutter run -d chrome
No devices found with name or id matching 'chrome'

いきなりはだめそう

> flutter devices
No devices detected.

Run "flutter emulators" to list and start any available device emulators.

If you expected your device to be detected, please run "flutter doctor" to
diagnose potential issues. You may also try increasing the time to wait for
connected devices with the --device-timeout flag. Visit https://flutter.dev/setup/
for troubleshooting tips.
tkttkt
$ flutter config --enable-web
> flutter channel beta
Switching to flutter channel 'beta'...
git: From https://github.com/flutter/flutter
git:  * [new branch]            Hixie-patch-3         -> origin/Hixie-patch-3
git:  * [new branch]            Hixie-patch-4         -> origin/Hixie-patch-4
git:  * [new branch]            alert-dialog          -> origin/alert-dialog
git:  + 022b333a08...8f89f6505b beta                  -> origin/beta  (forced update)
git:    a12e2a473a..63062a6443  dev                   -> origin/dev
git:  * [new branch]            devtools              -> origin/devtools
git:  + cc49058cb8...667b5e2cb7 experimental_skshaper -> origin/experimental_skshaper  (forced update)
git:    a12e2a473a..8f89f6505b  flutter-1.25-candidate.8 -> origin/flutter-1.25-candidate.8
git:  * [new branch]            flutter-1.26-candidate.0 -> origin/flutter-1.26-candidate.0
git:  * [new branch]            flutter-1.26-candidate.1 -> origin/flutter-1.26-candidate.1
git:  * [new branch]            flutter-1.26-candidate.2 -> origin/flutter-1.26-candidate.2
git:  * [new branch]            flutter-1.26-candidate.3 -> origin/flutter-1.26-candidate.3
git:  * [new branch]            flutter-1.26-candidate.4 -> origin/flutter-1.26-candidate.4
git:  * [new branch]            flutter-1.26-candidate.5 -> origin/flutter-1.26-candidate.5
git:  * [new branch]            flutter-1.26-candidate.6 -> origin/flutter-1.26-candidate.6
git:    78cbfbff42..d3a2259541  master                -> origin/master
git:  * [new branch]            revert-72304-flutter-engine-flutter-autoroll-ccbad057-c657-48c0-8ca6-c7a817e924d8-1607984013 -> origin/revert-72304-flutter-engine-flutter-autoroll-ccbad057-c657-48c0-8ca6-c7a817e924d8-1607984013
git:  * [new tag]               1.25.0-8.1.pre        -> 1.25.0-8.1.pre
git:  * [new tag]               1.26.0-1.0.pre        -> 1.26.0-1.0.pre
git: Switched to a new branch 'beta'
git: Branch 'beta' set up to track remote branch 'beta' from 'origin'.
Successfully switched to flutter channel 'beta'.
To ensure that you're on the latest build from this channel, run 'flutter upgrade'
> flutter upgrade
Downloading Dart SDK from Flutter engine 92ae191c17a53144bf4d62f3863c110be08e3fd3...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  174M  100  174M    0     0  24.8M      0  0:00:07  0:00:07 --:--:-- 30.1M
Building flutter tool...
Flutter is already up to date on channel beta
Flutter 1.25.0-8.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 8f89f6505b (3 weeks ago)2020-12-15 15:07:52 -0800
Engine • revision 92ae191c17
Tools • Dart 2.12.0 (build 2.12.0-133.2.beta)
> flutter devices
Downloading package sky_engine...                                  557ms
Downloading flutter_patched_sdk tools...                         1,018ms
Downloading flutter_patched_sdk_product tools...                   943ms
Downloading darwin-x64 tools...                                  1,661ms
Downloading darwin-x64/font-subset tools...                        500ms
1 connected device:

Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88
> flutter run -d chrome
Downloading Web SDK...                                           2,066ms
Because client depends on flutter_localizations any from sdk which depends on intl 0.17.0-nullsafety.2, intl 0.17.0-nullsafety.2 is required.
So, because client depends on intl ^0.16.0, version solving failed.     
Running "flutter pub get" in client...                                  
pub get failed (1; So, because client depends on intl ^0.16.0, version solving
failed.)
tkttkt

既存プロジェクトをとってきてるから、新規作成はしてない

tkttkt

run on android

> flutter run
Downloading android-arm-profile/darwin-x64 tools...              2,471ms
Downloading android-arm-release/darwin-x64 tools...                720ms
Downloading android-arm64-profile/darwin-x64 tools...              625ms
Downloading android-arm64-release/darwin-x64 tools...              539ms
Downloading android-x64-profile/darwin-x64 tools...                377ms
Downloading android-x64-release/darwin-x64 tools...                404ms
Launching lib/main.dart on Pixel 4 in debug mode...
Checking the license for package Android SDK Build-Tools 28.0.3 in /Users/tktcorporation/Library/Android/sdk/licenses
Warning: License for package Android SDK Build-Tools 28.0.3 not accepted.
Checking the license for package Android SDK Platform 29 in /Users/tktcorporation/Library/Android/sdk/licenses
Warning: License for package Android SDK Platform 29 not accepted.      
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;28.0.3 Android SDK Build-Tools 28.0.3                  
     platforms;android-29 Android SDK Platform 29                       
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
                                                                        
  Using Android SDK: /Users/tktcorporation/Library/Android/sdk          
                                                                        
* 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 4m 0s                                                   
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                       241.6s
Exception: Gradle task assembleDebug failed with exit code 1
tkttkt
> cd ~/Library/Android/sdk/tools/bin
tktcorporation@mbp ~/Library/Android/sdk/tools/bin> ./sdkmanager --licenses
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

https://qiita.com/joji/items/931d5f4e4ee853d7458c

ここ参考にやったけどだめだった

tkttkt

Java いれないとだめ?
そして入ってなかったっけ

tkttkt
tktcorporation@mbp ~ [1]> java -version
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

はいってないっぽ?

tkttkt

android studio で debug はいつもしてるからそこは問題ないはず

tkttkt
> pwd
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/jre/bin
> ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

java はどこ

tkttkt
> pwd
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin
> java --version
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
tkttkt

fish で通す方法わからんかったから
https://hsuzuki.hatenablog.com/entry/2015/12/22/125242
これ参考に

~/.config/fish/config.fish
set PATH $HOME/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home/bin:$PATH
set -x JAVA_HOME (/Applications/"Android Studio.app"/Contents/jre/jdk/Contents/Home)
tkttkt
> java --version
Unrecognized option: --version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

だめだった

tkttkt
$ ~/Library/Android/sdk/tools/bin/sdkmanager --licenses

通った
java --version はだめだったけど path としては通ってた?

tkttkt
> flutter run
Launching lib/main.dart on Pixel 4 in debug mode...
Checking the license for package Android SDK Build-Tools 28.0.3 in /Users/tktcorporation/Library/Android/sdk/licenses
License for package Android SDK Build-Tools 28.0.3 accepted.            
Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".  
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" ready.      
Installing Android SDK Build-Tools 28.0.3 in /Users/tktcorporation/Library/Android/sdk/build-tools/28.0.3
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" complete.   
"Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)" finished.   
Checking the license for package Android SDK Platform 29 in /Users/tktcorporation/Library/Android/sdk/licenses
License for package Android SDK Platform 29 accepted.                   
Preparing "Install Android SDK Platform 29 (revision: 5)".              
"Install Android SDK Platform 29 (revision: 5)" ready.                  
Installing Android SDK Platform 29 in /Users/tktcorporation/Library/Android/sdk/platforms/android-29
"Install Android SDK Platform 29 (revision: 5)" complete.               
"Install Android SDK Platform 29 (revision: 5)" finished.

run は通ったかんじ

このスクラップは2021/01/03にクローズされました