Update to a new version or branch

Important note: As of version 2.3 you have to use git to update. Updating via zip file does not work anymore..

Note: If updating to AndroidAPS 2.3, you need to use Android Studio Version 3.4, it doesn’t work with the latest one.

Install git (if you don’t have it)

Windows

  • Any git version should work. For example https://git-scm.com/download/win

  • Make sure to note down the installation path. You will need it in the next step.

    Git installation path

  • Let Studio know where is git.exe located: File - Settings

    Android Studio - open settings

  • In the next window: Version Control - Git

  • Choose correct path: .../Git/bin

  • Make sure update method “Merge” is selected.

    Android Studio - GIT path

Mac

  • Any git version should work. For example https://git-scm.com/download/mac
  • Use homebrew to install git: $ brew install git.
  • For details on installing git see the official git documentation.
  • If you install git via homebrew there is no need to change any preferences. Just in case: They can be found here: Android Studio - Preferences.

Update your local copy

  • Click: VCS->Git->Fetch

    Android Studio - GIT - Fetch

Selecting branch

  • If you want to change branch select another branch from tray: master (latest release) or another version (please see below)

and then checkout (You can use ‘Checkout as New Branch’ if ‘Checkout’ is not available.)

 ![](../images/UpdateAAPS2.png)

Updating branch from Github

  • Press Ctrl+T, select Merge method and press OK

On the tray you’ll see green message about updated project

Generate signed APK

In the menu select "Build" and then "Generate Signed Bundle / APK...". (The menu in Android Studio changed as of September 2018. In older versions select in the menu “Build” and then “Generate Signed APK...”.)

Signing means that you sign your generated app but in a digital way as a kind of digital fingerprint in the app itself. That is necessary because Android has a rule that it only accepts signed code to run for security reasons. For more information on this topic, follow the link here Security is a deep and complex topic and you don’t need this now.

Screenshot 39a

In the following dialogue box select “APK” instead of “Android App Bundle” and click button “Next”.

Screenshot 39b

Select “app” and click “Next”.

Screenshot 40

Enter your key store path, enter key store password, select key alias and enter key password.

Select ‘Remember passwords’.

Then click next.

Key store path

Select “full” as flavour for the generated app. Select V1 “Jar Signature” (V2 is optional) and click “Finish”. The following information might be important for later use.

  • ‘Release’ should be your default choice for “Build Type”, ‘Debug’ is just for people coding.
  • Select the build type you want to build.
    • full (i.e. recommendations automatically enacted in closed looping)
    • openloop (i.e. recommendations given to user to manually enact)
    • pumpcontrol (i.e. remote control for pump, no looping)
    • nsclient (i.e. looping data of another user is displayed and careportal entries can be added)

Screenshot 44

In the event log you see that the Signed APK was generated successfully.

Screenshot 45

Click the “locate” link in the event log.

Screenshot 46

Transfer APK to smartphone

A file manager window opens. It might look a bit different on your system as I am using Linux. On Windows there will be the File Explorer and on Mac OS X the Finder. There you should see the directory with the generated APK file. Unfortunately this is the wrong place as "wear-release.apk" is not the signed "app" APK we are searching for.

Screenshot 47

Please change to the directory AndroidAPS/app/full/release to find the “app-full-release.apk” file. Transfer this file to your Android smartphone. You can do it on your preferred way, i.e. Bluetooth, cloud upload, connect computer and phone by cable or use email. I use Gmail here in this example as it is fairly simple for me. I mention this because to install the self-signed app we need to allow Android on our smartphone to do this installation even if this file is received via Gmail which is normally forbidden. If you use something other please proceed accordingly.

Screenshot 48

In the settings of your smartphone there is an area “unknown apps install” where I have to give Gmail the right to install APK files which I get via Gmail.

Select “Allow from this source”. After the installation, you can disable it again.

Installation from unknown sources

The last step is to press on the APK file I got via Gmail and install the app. If the APK does not install and you have an older version of AndroidAPS on your phone that was signed with a different key then you will need to uninstall this first, remember to export your settings if so!

Yeah, you got it and can now start with configuring AndroidAPS for your use (CGMS, insulin pump) etc.

Check AAPS version on phone

You can check the AAPS version on your phone by clicking the three dots menu on the top right and then about.

AAPS version installed

Troubleshooting

Kotlin compiler warning

If build completed successfully but you get Kotlin compiler warnings then just ignore these warnings.

App was build successfully and can be transferred to phone.

ignore Kotline compiler warning

Could not download… / Offline Work

If you get a failure message like this

Warning could not download

make sure that ‘Offline work’ is disabled.

File -> Settings

Settings offline work

Uncommitted changes

If you receive failure message like

Failure uncommitted changes

Option 1

  • In Android Studio select VCS -> GIT -> Reset HEAD Reset HEAD

Option 2

  • Copy ‘git checkout –’ to clipboard (without quote signs)
  • Switch to Terminal in Android Studio (lower left side of Android Studio window) Android Studio Terminal
  • Paste copied text and press return GIT checkout success

App not installed

phone app note installed

  • Make sure you have transferred the “app-full-release.apk” file to your phone.
  • If “App not installed” is displayed on your phone follow these steps:
    1. Export settings (in AAPS version already installed on your phone)
    2. Uninstall AAPS on your phone.
    3. Enable airplane mode & turn off bluetooth.
    4. Install new version (“app-full-release.apk”)
    5. Import settings
    6. Turn bluetooth back on and disable airplane mode

App installed but old version

If you build the app successfully, transferred it to your phone and installed it successfully but the version number stays the same then you might have missed the merging step in the update manual.

None of the above worked

If non of the above tips helped you might consider building the app from scratch:

  1. Export settings (in AAPS version already installed on your phone)

  2. Have your key password and key store password ready In case you have forgotten passwords you can try to find them in project files as described here.

  3. Note down the path to your key store
    

    In Android Studio Build -> Generate Signed APK Key store path

  1. Build app from scratch as described here. Use existing key and key store.
  2. When you have build the APK successfully delete the exiting app on your phone, transfer the new apk to your phone and install.
  3. Import settings

Worst case scenario

In case even building the app from scratch does not solve your problem you might want to try to uninstall Android Studio completely. Some Users reported that this solved their problem.

Make sure to uninstall all files associated with Android Studio. Manuals can be found online i.e. https://stackoverflow.com/questions/39953495/how-to-completely-uninstall-android-studio-from-windowsv10.

Install Android Studio from scratch as described here and do not update gradle.