You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4.8 KiB

Quick Setup Guide (Android & iOS)

Android

Prerequisite

  • Java 8 SDK

    $ sudo apt-get install java-8-openjdk
    
  • snapd

    $ sudo apt install snapd
    
    # this will change Java jdk to 11java 
    $ sudo apt install android-sdk
    
    
    
        /home/AccountName/Android/Sdk
    
        /usr/lib/android-sdk
    
        /Library/Android/sdk/
    
        /Users/[USER]/Library/Android/sdk
    
    wget https://dl.google.com/android/repository/commandlinetools-linux-6609375_latest.zip
    unzip commandlinetools-linux-6609375_latest.zip -d cmdline-tools
    sudo mv cmdline-tools $ANDROID_HOME/
    export PATH=$ANDROID_HOME/cmdline-tools/tools/bin:$PATH
    
    sudo /usr/lib/android-sdk/cmdline-tools/tools/bin/sdkmanager --licenses
    
    $ sudo ./gradlew assembleRelease
    
  • Android SDK

    sudo apt-get install unzip
    
    # here you paste the link you grabbed in the developer.android.com site
    
    sudo -iu jenkins wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
    
    sudo -iu jenkins mkdir android-sdk
    
    sudo -iu jenkins unzip sdk-tools-linux-3859397.zip -d android-sdk
    
    # this step is important to accept the Android SDK license
    
    yes |sudo -iu jenkins android-sdk/tools/bin/sdkmanager --licenses
    
  • Android Emulator (Integration Test)

    # Download emulator
    $ sudo -iu jenkins android-sdk/tools/bin/sdkmanager --list --verbose
    
    # create Android Virtual Device instance
    $ echo no | $ANDROID_SDK_ROOT/tools/bin/avdmanager -v create avd --force --package 'system-images;android-25;google_apis;armeabi-v7a' --name Android25 --tag google_apis --abi armeabi-v7a
    
    # install Android Emulator as service (Using Supervisor)
    $ sudo apt-get install supervisor
    
    # apply configuration file
    $ sudo service supervisor restart
    
    $ sudo -iu jenkins android-sdk/platform-tools/adb devices
    
  • Supervisord configuration file /etc/supervisor/conf.d/emulator.conf to run emulator as service

    [program:emulator]
    
    command=/var/lib/jenkins/android-sdk/emulator/emulator -avd Android25 -no-window -noaudio -no-boot-anim -accel on -ports 5556,5557
    
    autostart=true
    
    user=jenkins
    
    environment=ANDROID_SDK_ROOT=/var/lib/jenkins/android-sdk
    
  • Jenkins Script for running integration test

    ANDROID_SERIAL=emulator-5556
    
    # wait for emulator to be up and fully booted, unlock screen
    
    $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
    
    ./gradlew connectedAndroidTest
    

Jenkins build

  • Once you have the source code in Jenkins, its time to build. If your project has a Gradle wrapper, thats what you should use
    • Task :

      • assembleDebug: APK Debug build
      • assembleRelease : APK release build
      • bundleRelease: Bundle APK release Size Limit : 150MB
    • Signing bundle

      • $ jarsigner -keystore $pathToKeystore app-release.aab $keyAlias
        
      • In android studio, to generate signed bundle
        Build => Generate Signed Bundle / APK
        
    • Flutter

      • flutter build apk will output to ./build\app\outputs\apk\release

      • flutter build appbundle will generated a publishing format aab

        # build\app\outputs\bundle\release\app-release.apk
        $ flutter build apk
        
        # build\app\outputs\bundle\release\app-release.aab
        $ flutter build appbundle
        

Next

  • Automate app signing & publishing

  • Improve build time (Accelerated Gradle Build)

    $ mkdir -p /var/lib/jenkins/.gradle
    
    $ echo org.gradle.daemon=true | sudo -iu jenkins tee -a /var/lib/jenkins/.gradle/gradle.properties
    

Configure Jenkins

  • Go to Manage Jenkins > Configure System
  • Check “Environment variables”
  • Add Name: ANDROID_HOME
  • Add Value: /var/lib/jenkins/android-sdk
  • Click “Apply” then “Save”

IOS

Prerequiste

  • Apple Mac H/W

  • Xcode

    $ xcode-select --install
    

Sample script

  • Build Script

    cd Example # again, we need to move directory
    
    mkdir -p output # this directory will contain the output of the tests
    
    xcrun xcodebuild -workspace BugfenderExample.xcworkspace \
    
        -scheme "BugfenderExample" \
    
        -sdk iphonesimulator \
    
        -destination 'platform=iOS Simulator,name=iPhone 6,OS=10.0' \
    
        -derivedDataPath './output' \
    
        test