Skip to content

Project Setup

smk762 edited this page Dec 30, 2022 · 5 revisions

Android builds from scratch

Linux (Ubuntu)

  • Install Android Studio

  • launch Android Studio, accept all licenses, proceed with standard components installation

  • install git

sudo apt-get update
sudo apt-get install git-all
git version

Don't forget to configure git user credentials

  • Install Android Studio cli
sudo apt update
sudo apt install adb android-sdk
  • clone flutter from official repo

Official instructions

git clone https://github.com/flutter/flutter.git $HOME/flutter
  • make sure you've got flutter binary in your PATH (AE: export PATH="$PATH:$HOME/flutter/bin")

  • set flutter to 2.8.1 version

cd ~/flutter
git fetch
git checkout tags/2.8.1
  • clone mobile repo to the directory with lowercase/underscore name
git clone https://github.com/KomodoPlatform/AtomicDEX-mobile.git $HOME/atomicdex_mobile
  • open $HOME/atomicdex_mobile/android in Android Studio, allow Studio to download correct versions of gradle, java, sdks, etc

  • install Flutter and Dart plugins for Android Studio

  • in terminal run flutter doctor

flutter --version
flutter doctor
# Likely you'll need to accept Android Licenses again
flutter doctor --android-licenses
  • create folders to place api library into:
mkdir -p ~/atomicdex_mobile/android/app/src/main/cpp/libs/arm64-v8a
mkdir -p ~/atomicdex_mobile/android/app/src/main/cpp/libs/armeabi-v7a
  • download required api libraries and extract libmm2.a into respective folders

Builds are available in AtomicDEX-API CI releases

  • build application
cd ~/atomicdex_mobile
flutter create . --org com.komodoplatform.atomicdex
./fetch_coins.sh
flutter build apk  # include build params here, debug build is done by default

Apks can be installed later with adb

  • alternatively connect Android device to your PC via USB and start app directly on it:
cd ~/atomicdex_mobile
flutter create . --org com.komodoplatform.atomicdex
./fetch_coins.sh
flutter run  # include build params here

Windows

  • download and install Android Studio and Android cli tools

  • launch Android Studio, accept all licenses, proceed with standard components installation

  • download and install git

  • clone flutter from official repo or get one here

  • make sure you've got flutter binary in your PATH (Drive:\path\to\flutter\bin)

  • set flutter to 2.8.1 version

cd Drive:\path\to\my\flutter
git fetch
git checkout tags/2.8.1
  • clone mobile repo
git clone https://github.com/KomodoPlatform/AtomicDEX-mobile.git
  • open Drive:\path\to\AtomicDEX-mobile\android in Android Studio, allow Studio to download correct versions of gradle, java, sdks, etc

  • install Flutter and Dart plugins for Android Studio

  • in terminal run flutter doctor

flutter --version
flutter doctor
# Likely you'll need to accept Android Licenses again
flutter doctor --android-licenses
  • create folders to place api library into:
mkdir -p Drive:\path\to\AtomicDEX-mobile\android\app\src\main\cpp\libs\arm64-v8a
mkdir -p Drive:\path\to\AtomicDEX-mobile\android\app\src\main\cpp\libs\armeabi-v7a
  • download required api libraries and extract libmm2.a into respective folders

Builds are available in AtomicDEX-API CI releases

  • build application
cd Drive:\path\to\AtomicDEX-mobile
.\fetch_coins.ps1
flutter build apk  # include build params here, debug build is done by default

APKs can be installed later with adb

  • alternatively connect Android device to your PC via USB and start app directly on it:
cd Drive:\path\to\AtomicDEX-mobile
.\fetch_coins.ps1
flutter run

MacOS

sudo xcode-select --install
sudo xcodebuild -license # accept Xcode licenses
  • Install Android Studio

  • Launch Android Studio, accept all licenses, proceed with standard components installation

  • Install hombrew from here

  • install git

brew install git
git version

Don't forget to configure git user credentials

  • Install Android Studio cli
brew install --cask android-sdk
  • clone flutter from official repo

Official instructions

git clone https://github.com/flutter/flutter.git $HOME/flutter
  • Add the flutter binary to your PATH export PATH="$PATH:$HOME/flutter/bin"

  • Set flutter to 2.8.1 version

cd ~/flutter
git fetch
git checkout tags/2.8.1
  • Clone the AtomicDEX mobile repository
git clone https://github.com/KomodoPlatform/AtomicDEX-mobile.git
  • Open $HOME/AtomicDEX-mobile/android in Android Studio, allow Studio to download correct versions of gradle, java, sdks, etc

  • Install Flutter and Dart plugins for Android Studio

  • In terminal, run flutter doctor

flutter --version
flutter doctor
# Likely you'll need to accept Android Licenses again
flutter doctor --android-licenses
  • Create folders for the AtomicDEX API library:
mkdir -p ~/AtomicDEX-mobile/android/app/src/main/cpp/libs/arm64-v8a
mkdir -p ~/AtomicDEX-mobile/android/app/src/main/cpp/libs/armeabi-v7a
  • Download or build the required API libraries and copy the libmm2.a files into their respective folders

  • Build AtomicDEX Mobile

cd ~/AtomicDEX-mobile
./fetch_coins.sh
flutter build apk  # include build params here, debug build is done by default

APKs can be installed later with ADB

  • Alternatively connect Android device to your PC via USB and start app directly on it:
cd ~/AtomicDEX-mobile
./fetch_coins.sh
flutter run  # include build params here

Additional info and possible build issues:

Check flutter doctor command, in most cases it will detect issues and provide instructions for resolution. Building the application in Android Studio may also detect your issues and/or versions incompatibilities.

  • Run app on device connected to PC via USB:
flutter run # --release/--prodile, (--debug is default if no build type flag is passed)
  • Confirm device is connected and recognised by the system. If you don't see your device, try a different cable or USB port.
flutter devices
  • If you see the error: adb server version (41) doesn't match this client (39); killing... make sure android studio is not running, and start adb from the command line.

  • Install APK over wifi

adb tcpip 5555                      # Restarts in TCP mode port: 5555
adb connect 192.168.0.108:5555      # Connects adb to phone
adb install -r ./build/app/outputs/flutter-apk/app-release.apk
  • Make sure you have Android CLI tools on PATH and available from terminal

For example, try to run android debug bridge

adb device

If you don't want to manage SDK/cli tools manually, in Android Stuido go Settings -> Apperance & Behaviour -> System Settings -> Android SDK -> SDK Tools and make sure command line tools (latest) are installed, you will need to reload Studio after and possibly reboot

  • your system may not recognize java installed with Android Studio, in this case you will need to install one manually, version 9+

https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html

Requires oracle account for downloads. You may have to reboot your PC(for WIndows) after installation, after reboot make sure you have correct JAVA_HOME Env var.

  • Linux additional adb debugging info:

If error: adb server version (41) doesn't match this client (39); killing...

It's likely a mismatch between system apt adb and studio adb. Search system for other versions of adb, and set the symlink to use the correct one.

ls -la $(which adb)

lrwxrwxrwx 1 root root 43 Nov 2 16:47 /usr/bin/adb -> /home/smk762/Android/Sdk/platform-tools/adb

For udev rules, refer to https://github.com/M0Rf30/android-udev-rules

You might need to put something like SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6864", MODE="0666", GROUP="plugdev", SYMLINK+="android_adb", OWNER="smk762" into **/etc/udev/rules.d/51-android.rules

Run sudo service udev restart so rules take effect. You might also need to start adb with sudo.

iOS builds from scratch

MacOS only

  • Install latest Xcode from AppStore or from apple dev

  • Install Xcode command line tools:

sudo xcode-select --install
sudo xcodebuild -license # accept Xcode licenses
  • If you don't have hombrew installed get one here

  • install git

brew install git
git version

Don't forget to configure git user credentials

  • clone flutter from official repo

Official instructions

git clone https://github.com/flutter/flutter.git $HOME/flutter
  • make sure you've got flutter binary in your PATH (AE: export PATH="$PATH:$HOME/flutter/bin")

  • set flutter to 2.8.1 version

cd ~/flutter
git fetch
git checkout tags/2.8.1
  • clone mobile repo
git clone https://github.com/KomodoPlatform/AtomicDEX-mobile.git
  • in terminal run flutter doctor
flutter --version
flutter doctor
  • download required api library and extract libmm2.a into AtomicDEX-mobile/ios directory

API library builds are available in AtomicDEX-API CI releases

You will need to connect your iOS device to building machine to proceed with next steps

  • Clean cocoapods, generate fresh ones with flutter run
rm -rf ios/Podfile ios/Pods/*
# Make sure you have correct Podfile.lock file and have not removed it!
git checkout ios/Podfile.lock
flutter run  # should fail
  • Setup team credentials in Xcode:

Open AtomicDEX-mobile/ios/Runner.xcworkspace in Xcode

Go Runner > Signing & Capabilities > Signing

Make sure 'Automatically manage signing' checkbox is enabled

Select your personal or dev team account, ensure Bundle ID is unique to you

  • Sign dependencies, and resolve FLutter or Xcode conflicts

In Xcode select your device to be the build target (At the top of the Xcode interface dropdown menu, change selection from Runner > Any iOS Device (arm64) to Runner > %user% iPhone )

Run the application (Start the active scheme button on top-left of Xcode interface), expect build to fail.

From errors you can access DKPhotoGallery and other unsigned dependencies, select your certificate to sign them

You should now be able to build AtomicDEX mobile for your device

  • Run the application from Xcode

To install the build on the device you will need to keep your device unlocked and possibly accept developer as Trusted

To do so on iPhone, go: Settings > General > VPN & Device Management and accept developer and application as Trusted

  • Run flutter release/debug/profile build instead of Xcode one:

After signing dependencies, in Xcode go: Runner > Build Settings > Deployment, here make sure you have iOS 11 as iOS Deployment Target.

You should be able to launch the flutter build now on your device. Dev/app should be still accepted as Trusted and the device kept unlocked during installation.

flutter run --release # --debug or --profile