Δημιουργώντας την εφαρμογή APK

Φτιάξτε το μόνοι σας, αντί να το κατεβάσετε

AndroidAPS δεν είναι διαθέσιμο για κατέβασμα λόγω κανονισμού για τις ιατρικές συσκευές. Είναι νόμιμο να χτίσει η εφαρμογή για δική σας χρήση, αλλά δεν πρέπει να δώσετε αντίγραφο σε άλλους! Δείτε το σελίδα FAQ για λεπτομέρειες.

## Σημαντικές σημειώσεις

Configuration on demand is not supported by the current version of the Android Gradle plugin!

Εάν η κατασκευή σας αποτύχει με σφάλμα σχετικά με τη διαμόρφωση “κατά παραγγελία”, μπορείτε να κάνετε τα εξής:

  • Open the Preferences window by clicking File > Settings (on Mac, Android Studio > Preferences).
  • In the left pane, click Build, Execution, Deployment > Compiler.
  • Uncheck the Configure on demand checkbox.
  • Click Apply or OK.

Αυτό το άρθρο χωρίζεται σε δύο μέρη.

  • In the overview part there is an explanation on what steps are necessary to build the APK file.
  • In the step by step walkthrough part you will find the screenshots of a concrete installation. Because the versions of Android Studio - the software development environment which we will use to build the APK - will change very quickly this will be not identical to your installation but it should give you a good starting point. Android Studio also runs on Windows, Mac OS X and Linux and there might be small differences in some aspects between each platform. If you find that something important is wrong or missing, please inform the facebook group “AndroidAPS users” or in the Gitter chats Android APS or AndroidAPSwiki so that we can have a look at this.

Step by step walkthrough

Detailed description of the steps necessary to build the APK file.

Εγκαταστήστε το git (αν δεν το έχετε)

Follow the manual on the git installation page.

Install Android Studio

The following screenshots have been taken from Android Studio Version 3.6.1. Your screen might look a bit different if you use a newer version of Android Studio. But you should be able to find your way through. Help from the community is provided.

One of the most important things when installing Android Studio: Be patient! During installation and setup Android Studio is downloading a lot of stuff which will take its time.

Install Android Studio and setup during first start.

Select “Do not import settings” as you have not used it before.

Do not import settings

Decide whether you want to share data with Google or not.

Share data with Google

On the following screen click “Next”.

Welcome screen

Select “Standard” installation and click “Next”.

Standard installation

Select the theme for the user interface you like. (In this manual we used “Light”.) Then click “Next”. This is just the color scheme. You can select any you like (i.e. “Darcula” for dark mode). This selection has no influence on building the APK.

UI color scheme

Click “Finish” on the “Verify Settings” dialog.

Verify settings

Wait while Android Studio downloads additional components and be patient. Once everything is downloaded button “Finish” turns blue. Click the button now.

Downloading components

Set git path in preferences

Make sure git is installed on your computer.

On the Android Studio welcome screen click the small triangle (1. in next screenshot) and select “Settings” (2.).

Android Studio settings from welcome screen

Windows

  • Click the small triangle next to Version Control (1.) to open the sub-menu.
  • Click Git (2.).
  • Make sure update method “Merge” (3.) is selected.
  • Check if Android Studio can locate path to git.exe automatically by clicking the button “Test” (4.)

Android Studio settings

  • If automatic setting is successful git version will be displayed.
  • Click “OK” in the dialog box (1.) and “OK” in the settings window (2.).

Automatic git installation succeeded

  • In case file git.exe cannot be found click “OK” in the dialog box (1.) and then the button with the three dots (2.).
  • Use search function in windows explorer to find “git.exe” if you are unsure where it can be found. You are looking for git.exe located in \bin\ folder.
  • Select path to git.exe and make sure you selected the one in ** \bin\ ** folder (3.) and click “OK” (4.).
  • Close settings window by clicking “OK” button (5.).

Automatic git installation failed

  • Reboot your computer to update system environment.

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.

Download AndroidAPS code

  • If you haven’t already rebooted your computer after setting git path in preferences do it now. System environment must be updated.
  • On the Android Studio welcome screen click the small triangle right of “Check out project from version control” (1.).
  • Select “Git” (2.).

Check out project from version control from welcome screen

  • If you already opened Android Studio and do not see the welcome screen anymore select File (1.) > New (2.) > Project from Version Control... (3.) > Git (4.).

Check out project from version control within Android Studio

  • Fill in the URL to the main AndroidAPS repository (“https://github.com/MilosKozak/AndroidAPS”) (1.).
  • Choose the directory where you want to save the cloned code.
  • Click button “Test” (2.).
  • If test cannot be completed successfully check URL, correct and click “Test” again.
  • If URL is entered correctly “Connection successful” (3.) will be shown.
  • Click button “Clone” (4.).

Clone repository

  • Do not click “Background” while repository is cloned!

Clone repository - no background action

  • After repository is cloned successfully open your local copy by clicking “Yes”.

Open repository

  • In the lower right corner you will see the information that Android Studio is running background tasks.

Background tasks

  • Grant access if your firewall is asking for permission.

Firewall permission java

  • Once the background tasks are finished you will probably see the following error message:

SDK licence

Download Android SDK

  • Click File > Settings.

Open settings

  • Click the small triangle next to Appearance & Behaviour (1.).
  • Click the small triangle next to System Settings (2.) and select Android SDK (3.)
  • Check the box left of “Android 9.0 (Pie)” (4.) (API Level 28).

SDK settings

  • Confirm changes by clicking OK.

Confirm SDK changes

  • Accept licence agreement (1.) and click “Next” (2.).

Accept SDK licence

  • Wait until installation is finished.

Wait during SDK installation

  • When SDK installation is completed the “Finish” button will turn blue. Click this button.

Finish SDK installation

  • Android Studio might recommend to update the gradle system. Never update gradle! This might lead to difficulties!
  • If you see an information on the lower right side of your Android Studio window that Android Gradle Plugin is ready to update click on the text “update” (1.) and in the dialog box on “Don’t remind me again for this project” (2.).

No cradle update

Δημιουργία υπογεγραμμένου APK

Signing means that you indicate your app to be your own creation but in a digital way as a kind of digital fingerprint within the app itself. Αυτό είναι απαραίτητο επειδή το Android έχει έναν κανόνα ότι δέχεται μόνο υπογεγραμμένο κώδικα για εκτέλεση για λόγους ασφαλείας. For more information on this topic, follow this link.

  • Click “Build” in the menu bar and select “Generate Signed Bundle / APK...”.

Build apk

  • Select “APK” (1.) instead of “Android App Bundle” and click “Next” (2.).

APK instead of bundle

  • Make sure that module is set to “app” (1.).

  • Click “Create new...” (2.) to start creating your key store.

    A key store in this case is nothing more than a file in which the information for signing is stored. It is encrypted and the information is secured with passwords.

Create key store

  • Click the folder symbol (1.) to select your key store path.
  • Select the path where your key store shall be saved (2.). Do not save in same folder as project. You must use a different directory! One option might be your home folder.
  • Type a file name for your key store (3.).
  • Click “OK” (4.).
  • Passwords for key store and key do not have to be very sophisticated. Make sure to remember those or make a note in a safe place. In case you will not remember your passwords in the future you see troubleshooting for lost key store.
  • Enter (5.) and confirm (6.) the password for your key store.
  • Do the same for your key (7. + 8.).
  • Validity (9.) is 25 years by default. You do not have to change the default value.
  • First and last name must be entered (10.). All other information is optional.
  • Click “OK” (11.) when you are done.

Key store path

  • Make sure the box to remember passwords is checked (1.). So you don’t have to enter them again next time you build the apk (i.e. when updating to a new AndroidAPS version).
  • Click “Next” (2.).

Remember passwords

  • Select build variant “fullRelease” (1.).
  • Check boxes V1 and V2 for signature versions (2.).
  • Click “Finish”. (3.)

Finish build

  • Android Studio will display the information “APK(s) generated successfully...” after build is finished.
  • In case build was not successful refer to the troubleshooting section.
  • Easiest way to find the apk is to click on “Event log”.

Build successfully - event log

  • In the event log section click “locate”.

Event log - locate apk

  • app-full-release.apk is the file you are looking for.

File location apk

Μεταφορά APK σε smartphone

Easiest way to transfer app-full-release.apk to your phone is via USB cable or Google Drive. Please note that transfer by mail might cause difficulties and is not the preferred way.

On your phone you have to allow installation from unknown sources. Manuals how to do this can be found on the internet (i.e. here or here).

Identify receiver if using xDrip+

See xDrip+ page

Αντιμετώπιση προβλημάτων

See separate page troubleshooting Android Studio.