Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Last active August 3, 2020 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ltfschoen/82aff048fd3e0cdd27b093ad6d93c3da to your computer and use it in GitHub Desktop.
Save ltfschoen/82aff048fd3e0cdd27b093ad6d93c3da to your computer and use it in GitHub Desktop.
flutter-notes.md

https://flutter.dev/docs/get-started/install/macos

  • Download Flutter for macOS

  • Extract

cd ~/development
unzip ~/Downloads/flutter_macos_v1.12.13+hotfix.9-stable.zip
mkdir -p $HOME/development
mv ./flutter $HOME/development/
code ~/.bash_profile
  • Add to PATH
export PATH="$HOME/development/flutter/bin:$PATH"
git clone https://github.com/flutter/flutter.git -b stable
./flutter/bin/flutter doctor
./flutter/bin/flutter doctor --android-licenses

cd ./lib/js_service_kusama && yarn install && yarn run build && cd ../..
cd ./lib/js_service_acala && yarn install && yarn run build && cd ../..
cd ./lib/js_service_laminar && yarn install && yarn run build && cd ../..
  • Note: If you run git clone https://github.com/flutter/flutter.git -b beta or git clone https://github.com/flutter/flutter.git (master), then you may get errors when you run flutter run --flavor prod like:
../../../../.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {                          
                         ^^^^^^^^^^^^^^^^^^^                            
../../../../.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found.
abstract class PictureStreamCompleter with DiagnosticableMixin {        
                                           ^^^^^^^^^^^^^^^^^^^ 
...

Preferences > Languages & Frameworks > Dart SDK /Users/ls/code/src/ltfschoen/polkawallet-flutter/flutter/bin/cache/dart-sdk

Preferences > Languages & Frameworks > Flutter /Users/ls/code/src/ltfschoen/polkawallet-flutter/flutter

  • Refresh terminal
source ~/.bash_profile
  • Check for dependencies
flutter upgrade
flutter doctor
flutter doctor --android-licenses
# export ANDROID_HOME=$HOME/.android
export ANDROID_HOME=$HOME/Library/Android/sdk
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH="$ANDROID_SDK_ROOT/tools/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
source ~/.bash_profile
echo $ANDROID_HOME
sdkmanager --help
adb --help
  • Install Xcode
  • Install Cocoapods
brew reinstall cocoapods
brew link --overwrite cocoapods
  • Install Dart-Flutter VSCode extension
code --install-extension Dart-Code.flutter
  • On device do the following otherwise will get error Device xyz is not authorized.
    • USB debugging checkbox "enabled"
    • Developer Options > Revoke USB Debugging Authorizations
    • Default USB configuration > USB tethering
      • Click "OK" in alert that appears labelled "Allow USB debugging?" and select checkbox "Always allow from this computer"
  • Reconnect device, then agree to RSA Fingerprint verification window
  • Check if device connected
flutter devices -v
flutter devices
nvm use v13.12.0
cd ./lib/js_service_kusama && rm yarn.lock && yarn && yarn run build && cd ../../
cd ./lib/js_service_acala && rm yarn.lock && yarn && yarn run build && cd ../../
cd ./lib/js_service_laminar && rm yarn.lock && yarn && yarn run build && cd ../../
flutter doctor -v
flutter clean
flutter run -v
  • Uninstall any existing versions of app from the device
  • Run on the specific device that is connected, where flutter devices returns and id.
flutter run -d 988a1644544349575a30 -v
flutter run -d 988a1644544349575a30 -v --observatory-port 8888 --disable-service-auth-codes lib/main.dart
  • To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
flutter packages pub run build _runner watch

Build APK

Sign app

Create keystore

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

Reference keystore from app

touch ./android/key.properties

Add to .gitignore

/android/key.properties

Add to contents of key.properties file:

storePassword=
keyPassword=
keyAlias=key
storeFile=/Users/ls/key.jks

Add password that was used when running keytool in sections above

Edit /android/app/build.gradle

Replace with:

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
            // storeFile rootProject.file("app/key.jks")
            // storePassword System.getenv("APPCENTER_KEYSTORE_PASSWORD")
            // keyAlias System.getenv("APPCENTER_KEY_ALIAS")
            // keyPassword System.getenv("APPCENTER_KEY_PASSWORD")
        }
    }

Build APK

flutter build apk --split-per-abi

Upload APK files to https://drive.google.com/drive/u/1/folders/1-QmI0dhlhw6jXqwIuQuuNqZi3uny5hvu, those that were generated in: build/app/outputs/apk/release/

Build for AppCentre

Go to https://appcenter.ms/orgs/MXC-Foundation-gGmbH/apps/DHXDashAndroid/build/branches

Follow the "AppCentre Setup" instructions here https://buildflutter.com/deploying-flutter-apps-via-appcenter/

Add all environment variables from .env file

Notify "Collaborators/QA"

Troubleshooting

adb shell

> logcat
adb kill-server

Or run the following before running on device to see what Observatory port is connected

adb logcat -e flutter\|Observatory
adb logcat -e flutter\|Observatory *:I

I've gone through these related issues:

flutter/flutter#25455 flutter/flutter#33214 flutter/flutter#19770 flutter/flutter#51269 https://medium.com/flutter-community/hot-reload-for-flutter-integration-tests-e0478b63bd54

IGNORE THE BELOW

Install VS Code Flutter Dart from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✗] Xcode - develop for iOS and macOS ✗ Xcode installation is incomplete; a full installation is necessary for iOS development. Download at: https://developer.apple.com/xcode/download/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch ✗ CocoaPods not installed. CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To install: sudo gem install cocoapods

iOS - flutter attach --debug-uri - flutter/flutter#33214 (comment)

flutter emulators --create --name pixel

sdkmanager "system-images;android-27;google_apis_playstore;x86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment