URI: 
       tMerge pull request #6227 from spesmilo/mv_android - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 16b14d6f06f712aebfe09fdae0e80eb6aaf401e0
   DIR parent ba5ccf464c2a94feed62e28cf12bea125ad20d99
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Fri, 12 Jun 2020 21:22:50 +0200
       
       Merge pull request #6227 from spesmilo/mv_android
       
       move android stuff to contrib/android
       Diffstat:
         M .travis.yml                         |       4 ++--
         R electrum/gui/kivy/tools/Dockerfile… |       0 
         A contrib/android/Makefile            |      33 +++++++++++++++++++++++++++++++
         A contrib/android/Readme.md           |     127 +++++++++++++++++++++++++++++++
         R electrum/gui/kivy/tools/bitcoin_in… |       0 
         R electrum/gui/kivy/tools/blacklist.… |       0 
         A contrib/android/buildozer.spec      |     225 +++++++++++++++++++++++++++++++
         A contrib/android/make_apk            |      58 ++++++++++++++++++++++++++++++
         D contrib/make_apk                    |      58 ------------------------------
         D electrum/gui/kivy/Makefile          |      33 -------------------------------
         D electrum/gui/kivy/Readme.md         |     127 -------------------------------
         D electrum/gui/kivy/tools/buildozer.… |     226 -------------------------------
       
       12 files changed, 445 insertions(+), 446 deletions(-)
       ---
   DIR diff --git a/.travis.yml b/.travis.yml
       t@@ -65,12 +65,12 @@ jobs:
              install:
                - pip install requests && ./contrib/pull_locale
                - ./contrib/make_packages
       -        - sudo docker build --no-cache -t electrum-android-builder-img electrum/gui/kivy/tools
       +        - sudo docker build --no-cache -t electrum-android-builder-img contrib/android
              script:
                - sudo chown -R 1000:1000 .
                # Output something every minute or Travis kills the job
                - while sleep 60; do echo "=====[ $SECONDS seconds still running ]====="; done &
       -        - sudo docker run -it -u 1000:1000 --rm --name electrum-android-builder-cont --env CI=true -v $PWD:/home/user/wspace/electrum --workdir /home/user/wspace/electrum electrum-android-builder-img ./contrib/make_apk
       +        - sudo docker run -it -u 1000:1000 --rm --name electrum-android-builder-cont --env CI=true -v $PWD:/home/user/wspace/electrum --workdir /home/user/wspace/electrum electrum-android-builder-img ./contrib/android/make_apk
                # kill background sleep loop
                - kill %1
                - ls -la bin
   DIR diff --git a/electrum/gui/kivy/tools/Dockerfile b/contrib/android/Dockerfile
   DIR diff --git a/contrib/android/Makefile b/contrib/android/Makefile
       t@@ -0,0 +1,33 @@
       +PYTHON = python3
       +
       +# needs kivy installed or in PYTHONPATH
       +
       +.PHONY: theming apk clean
       +
       +theming:
       +        #bash -c 'for i in network lightning; do convert -background none theming/light/$i.{svg,png}; done'
       +        $(PYTHON) -m kivy.atlas ../../electrum/gui/kivy/theming/light 1024 ../../electrum/gui/kivy/theming/light/*.png
       +prepare:
       +        # running pre build setup
       +        @cp buildozer.spec ../../buildozer.spec
       +        # copy electrum to main.py
       +        @cp ../../run_electrum ../../main.py
       +        @-if [ ! -d "../../.buildozer" ];then \
       +                cd ../..; buildozer android debug;\
       +                cp -f blacklist.txt .buildozer/android/platform/python-for-android/src/blacklist.txt;\
       +                rm -rf ./.buildozer/android/platform/python-for-android/dist;\
       +        fi
       +apk:
       +        @make prepare
       +        @-cd ../..; buildozer android debug deploy run
       +        @make clean
       +release:
       +        @make prepare
       +        @-cd ../..; buildozer android release
       +        @make clean
       +clean:
       +        # Cleaning up
       +        # rename main.py to electrum
       +        @-rm ../../main.py
       +        # remove buildozer.spec
       +        @-rm ../../buildozer.spec
   DIR diff --git a/contrib/android/Readme.md b/contrib/android/Readme.md
       t@@ -0,0 +1,127 @@
       +# Kivy GUI
       +
       +The Kivy GUI is used with Electrum on Android devices.
       +To generate an APK file, follow these instructions.
       +
       +## Android binary with Docker
       +
       +✗ _This script does not produce reproducible output (yet!).
       +   Please help us remedy this._
       +
       +This assumes an Ubuntu (x86_64) host, but it should not be too hard to adapt to another
       +similar system. The docker commands should be executed in the project's root
       +folder.
       +
       +1. Install Docker
       +
       +    ```
       +    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
       +    $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
       +    $ sudo apt-get update
       +    $ sudo apt-get install -y docker-ce
       +    ```
       +
       +2. Build image
       +
       +    ```
       +    $ sudo docker build -t electrum-android-builder-img contrib/android
       +    ```
       +
       +3. Build locale files
       +
       +    ```
       +    $ ./contrib/pull_locale
       +    ```
       +
       +4. Prepare pure python dependencies
       +
       +    ```
       +    $ ./contrib/make_packages
       +    ```
       +
       +5. Build binaries
       +
       +    ```
       +    $ mkdir --parents $PWD/.buildozer/.gradle
       +    $ sudo docker run -it --rm \
       +        --name electrum-android-builder-cont \
       +        -v $PWD:/home/user/wspace/electrum \
       +        -v $PWD/.buildozer/.gradle:/home/user/.gradle \
       +        -v ~/.keystore:/home/user/.keystore \
       +        --workdir /home/user/wspace/electrum \
       +        electrum-android-builder-img \
       +        ./contrib/android/make_apk
       +    ```
       +    This mounts the project dir inside the container,
       +    and so the modifications will affect it, e.g. `.buildozer` folder
       +    will be created.
       +
       +5. The generated binary is in `./bin`.
       +
       +
       +
       +## FAQ
       +
       +### I changed something but I don't see any differences on the phone. What did I do wrong?
       +You probably need to clear the cache: `rm -rf .buildozer/android/platform/build/{build,dists}`
       +
       +
       +### How do I deploy on connected phone for quick testing?
       +Assuming `adb` is installed:
       +```
       +$ adb -d install -r bin/Electrum-*-arm64-v8a-debug.apk
       +$ adb shell monkey -p org.electrum.electrum 1
       +```
       +
       +
       +### How do I get an interactive shell inside docker?
       +```
       +$ sudo docker run -it --rm \
       +    -v $PWD:/home/user/wspace/electrum \
       +    -v $PWD/.buildozer/.gradle:/home/user/.gradle \
       +    --workdir /home/user/wspace/electrum \
       +    electrum-android-builder-img
       +```
       +
       +
       +### How do I get more verbose logs for the build?
       +See `log_level` in `buildozer.spec`
       +
       +
       +### How can I see logs at runtime?
       +This should work OK for most scenarios:
       +```
       +adb logcat | grep python
       +```
       +Better `grep` but fragile because of `cut`:
       +```
       +adb logcat | grep -F "`adb shell ps | grep org.electrum.electrum | cut -c14-19`"
       +```
       +
       +
       +### Kivy can be run directly on Linux Desktop. How?
       +Install Kivy.
       +
       +Build atlas: `(cd electrum/gui/kivy/; make theming)`
       +
       +Run electrum with the `-g` switch: `electrum -g kivy`
       +
       +### debug vs release build
       +If you just follow the instructions above, you will build the apk
       +in debug mode. The most notable difference is that the apk will be
       +signed using a debug keystore. If you are planning to upload
       +what you build to e.g. the Play Store, you should create your own
       +keystore, back it up safely, and run `./contrib/make_apk release`.
       +
       +See e.g. [kivy wiki](https://github.com/kivy/kivy/wiki/Creating-a-Release-APK)
       +and [android dev docs](https://developer.android.com/studio/build/building-cmdline#sign_cmdline).
       +
       +### Access datadir on Android from desktop (e.g. to copy wallet file)
       +Note that this only works for debug builds! Otherwise the security model
       +of Android does not let you access the internal storage of an app without root.
       +(See [this](https://stackoverflow.com/q/9017073))
       +```
       +$ adb shell
       +$ run-as org.electrum.electrum ls /data/data/org.electrum.electrum/files/data
       +$ run-as org.electrum.electrum cp /data/data/org.electrum.electrum/files/data/wallets/my_wallet /sdcard/some_path/my_wallet
       +```
   DIR diff --git a/electrum/gui/kivy/tools/bitcoin_intent.xml b/contrib/android/bitcoin_intent.xml
   DIR diff --git a/electrum/gui/kivy/tools/blacklist.txt b/contrib/android/blacklist.txt
   DIR diff --git a/contrib/android/buildozer.spec b/contrib/android/buildozer.spec
       t@@ -0,0 +1,225 @@
       +[app]
       +
       +# (str) Title of your application
       +title = Electrum
       +
       +# (str) Package name
       +package.name = Electrum
       +
       +# (str) Package domain (needed for android/ios packaging)
       +package.domain = org.electrum
       +
       +# (str) Source code where the main.py live
       +source.dir = .
       +
       +# (list) Source files to include (let empty to include all the files)
       +source.include_exts = py,png,jpg,kv,atlas,ttf,txt,gif,pem,mo,vs,fs,json,csv
       +
       +# (list) Source files to exclude (let empty to not exclude anything)
       +source.exclude_exts = spec
       +
       +# (list) List of directory to exclude (let empty to not exclude anything)
       +source.exclude_dirs = bin, build, dist, contrib,
       +    electrum/tests,
       +    electrum/gui/qt,
       +    electrum/gui/kivy/theming/light
       +# (list) List of exclusions using pattern matching
       +source.exclude_patterns = Makefile,setup*
       +
       +# (str) Application versioning (method 1)
       +version.regex = APK_VERSION = '(.*)'
       +version.filename = %(source.dir)s/electrum/version.py
       +
       +# (str) Application versioning (method 2)
       +#version = 1.9.8
       +
       +# (list) Application requirements
       +requirements =
       +    # note: re python3.8, see #6147
       +    hostpython3==3.7.7,
       +    python3==3.7.7,
       +    android,
       +    openssl,
       +    plyer,
       +    # kivy 1.11.1
       +    kivy==39c17457bae91baf8fe710dc989791e45879f136,
       +    libffi,
       +    libsecp256k1,
       +    cryptography
       +
       +# (str) Presplash of the application
       +#presplash.filename = %(source.dir)s/gui/kivy/theming/splash.png
       +presplash.filename = %(source.dir)s/electrum/gui/icons/electrum_presplash.png
       +
       +# (str) Icon of the application
       +icon.filename = %(source.dir)s/electrum/gui/icons/electrum_launcher.png
       +
       +# (str) Supported orientation (one of landscape, portrait or all)
       +orientation = portrait
       +
       +# (bool) Indicate if the application should be fullscreen or not
       +fullscreen = False
       +
       +
       +#
       +# Android specific
       +#
       +
       +# (list) Permissions
       +android.permissions = INTERNET, CAMERA, WRITE_EXTERNAL_STORAGE
       +
       +# (int) Android API to use
       +android.api = 28
       +
       +# (int) Minimum API required. You will need to set the android.ndk_api to be as low as this value.
       +android.minapi = 21
       +
       +# (str) Android NDK version to use
       +android.ndk = 19c
       +
       +# (int) Android NDK API to use (optional). This is the minimum API your app will support.
       +android.ndk_api = 21
       +
       +# (bool) Use --private data storage (True) or --dir public storage (False)
       +android.private_storage = True
       +
       +# (str) Android NDK directory (if empty, it will be automatically downloaded.)
       +android.ndk_path = /opt/android/android-ndk
       +
       +# (str) Android SDK directory (if empty, it will be automatically downloaded.)
       +android.sdk_path = /opt/android/android-sdk
       +
       +# (str) ANT directory (if empty, it will be automatically downloaded.)
       +android.ant_path = /opt/android/apache-ant
       +
       +# (str) Android entry point, default is ok for Kivy-based app
       +#android.entrypoint = org.renpy.android.PythonActivity
       +
       +# (list) List of Java .jar files to add to the libs so that pyjnius can access
       +# their classes. Don't add jars that you do not need, since extra jars can slow
       +# down the build process. Allows wildcards matching, for example:
       +# OUYA-ODK/libs/*.jar
       +#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar
       +#android.add_jars = lib/android/zbar.jar
       +
       +# (list) List of Java files to add to the android project (can be java or a
       +# directory containing the files)
       +android.add_src = electrum/gui/kivy/data/java-classes/
       +
       +android.gradle_dependencies = me.dm7.barcodescanner:zxing:1.9.8
       +
       +android.add_activities = org.electrum.qr.SimpleScannerActivity
       +
       +# (str) python-for-android branch to use, if not master, useful to try
       +# not yet merged features.
       +#android.branch = master
       +
       +# (str) OUYA Console category. Should be one of GAME or APP
       +# If you leave this blank, OUYA support will not be enabled
       +#android.ouya.category = GAME
       +
       +# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
       +#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
       +
       +# (str) XML file to include as an intent filters in <activity> tag
       +android.manifest.intent_filters = contrib/android/bitcoin_intent.xml
       +
       +# (str) launchMode to set for the main activity
       +android.manifest.launch_mode = singleTask
       +
       +# (list) Android additionnal libraries to copy into libs/armeabi
       +#android.add_libs_armeabi = lib/android/*.so
       +
       +# (bool) Indicate whether the screen should stay on
       +# Don't forget to add the WAKE_LOCK permission if you set this to True
       +#android.wakelock = False
       +
       +# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
       +# note: can be overwritten by APP_ANDROID_ARCH env var
       +android.arch = armeabi-v7a
       +
       +# (list) Android application meta-data to set (key=value format)
       +#android.meta_data =
       +
       +# (list) Android library project to add (will be added in the
       +# project.properties automatically.)
       +#android.library_references =
       +
       +android.whitelist = lib-dynload/_csv.so
       +
       +
       +#
       +# Python for android (p4a) specific
       +#
       +
       +# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
       +p4a.source_dir = /opt/python-for-android
       +
       +# (str) The directory in which python-for-android should look for your own build recipes (if any)
       +#p4a.local_recipes =
       +
       +# (str) Filename to the hook for p4a
       +#p4a.hook =
       +
       +# (str) Bootstrap to use for android builds
       +# p4a.bootstrap = sdl2
       +
       +# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
       +#p4a.port =
       +
       +
       +#
       +# iOS specific
       +#
       +
       +# (str) Name of the certificate to use for signing the debug version
       +# Get a list of available identities: buildozer ios list_identities
       +#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"
       +
       +# (str) Name of the certificate to use for signing the release version
       +#ios.codesign.release = %(ios.codesign.debug)s
       +
       +
       +
       +[buildozer]
       +
       +# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
       +log_level = 1
       +
       +
       +# -----------------------------------------------------------------------------
       +# List as sections
       +#
       +# You can define all the "list" as [section:key].
       +# Each line will be considered as a option to the list.
       +# Let's take [app] / source.exclude_patterns.
       +# Instead of doing:
       +#
       +#     [app]
       +#     source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
       +#
       +# This can be translated into:
       +#
       +#     [app:source.exclude_patterns]
       +#     license
       +#     data/audio/*.wav
       +#     data/images/original/*
       +#
       +
       +# -----------------------------------------------------------------------------
       +# Profiles
       +#
       +# You can extend section / key with a profile
       +# For example, you want to deploy a demo version of your application without
       +# HD content. You could first change the title to add "(demo)" in the name
       +# and extend the excluded directories to remove the HD content.
       +#
       +#     [app@demo]
       +#     title = My Application (demo)
       +#
       +#     [app:source.exclude_patterns@demo]
       +#     images/hd/*
       +#
       +# Then, invoke the command line with the "demo" profile:
       +#
       +#     buildozer --profile demo android debug
   DIR diff --git a/contrib/android/make_apk b/contrib/android/make_apk
       t@@ -0,0 +1,58 @@
       +#!/bin/bash
       +
       +set -e
       +
       +CONTRIB_ANDROID="$(dirname "$(readlink -e "$0")")"
       +ROOT_FOLDER="$CONTRIB_ANDROID"/../..
       +PACKAGES="$ROOT_FOLDER"/packages/
       +LOCALE="$ROOT_FOLDER"/electrum/locale/
       +
       +if [ ! -d "$LOCALE" ]; then
       +  echo "Run pull_locale first!"
       +  exit 1
       +fi
       +
       +if [ ! -d "$PACKAGES" ]; then
       +  echo "Run make_packages first!"
       +  exit 1
       +fi
       +
       +pushd ./contrib/android
       +
       +make theming
       +
       +if [[ -n "$1"  && "$1" == "release" ]] ; then
       +    echo -n Keystore Password:
       +    read -s password
       +    export P4A_RELEASE_KEYSTORE=~/.keystore
       +    export P4A_RELEASE_KEYSTORE_PASSWD=$password
       +    export P4A_RELEASE_KEYALIAS_PASSWD=$password
       +    export P4A_RELEASE_KEYALIAS=electrum
       +    # build two apks
       +    export APP_ANDROID_ARCH=armeabi-v7a
       +    make release
       +    export APP_ANDROID_ARCH=arm64-v8a
       +    make release
       +else
       +    export P4A_DEBUG_KEYSTORE="$CONTRIB_ANDROID"/android_debug.keystore
       +    export P4A_DEBUG_KEYSTORE_PASSWD=unsafepassword
       +    export P4A_DEBUG_KEYALIAS_PASSWD=unsafepassword
       +    export P4A_DEBUG_KEYALIAS=electrum
       +    # create keystore if needed
       +    if [ ! -f "$P4A_DEBUG_KEYSTORE" ]; then
       +        keytool -genkey -v -keystore "$CONTRIB_ANDROID"/android_debug.keystore \
       +            -alias "$P4A_DEBUG_KEYALIAS" -keyalg RSA -keysize 2048 -validity 10000 \
       +            -dname "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB" \
       +            -storepass "$P4A_DEBUG_KEYSTORE_PASSWD" \
       +            -keypass "$P4A_DEBUG_KEYALIAS_PASSWD"
       +    fi
       +    # build two apks (only one on Travis CI)
       +    export APP_ANDROID_ARCH=armeabi-v7a
       +    make apk
       +    if [ ! $CI ]; then
       +        export APP_ANDROID_ARCH=arm64-v8a
       +        make apk
       +    fi
       +fi
       +
       +popd
   DIR diff --git a/contrib/make_apk b/contrib/make_apk
       t@@ -1,58 +0,0 @@
       -#!/bin/bash
       -
       -set -e
       -
       -CONTRIB="$(dirname "$(readlink -e "$0")")"
       -ROOT_FOLDER="$CONTRIB"/..
       -PACKAGES="$ROOT_FOLDER"/packages/
       -LOCALE="$ROOT_FOLDER"/electrum/locale/
       -
       -if [ ! -d "$LOCALE" ]; then
       -  echo "Run pull_locale first!"
       -  exit 1
       -fi
       -
       -if [ ! -d "$PACKAGES" ]; then
       -  echo "Run make_packages first!"
       -  exit 1
       -fi
       -
       -pushd ./electrum/gui/kivy/
       -
       -make theming
       -
       -if [[ -n "$1"  && "$1" == "release" ]] ; then
       -    echo -n Keystore Password:
       -    read -s password
       -    export P4A_RELEASE_KEYSTORE=~/.keystore
       -    export P4A_RELEASE_KEYSTORE_PASSWD=$password
       -    export P4A_RELEASE_KEYALIAS_PASSWD=$password
       -    export P4A_RELEASE_KEYALIAS=electrum
       -    # build two apks
       -    export APP_ANDROID_ARCH=armeabi-v7a
       -    make release
       -    export APP_ANDROID_ARCH=arm64-v8a
       -    make release
       -else
       -    export P4A_DEBUG_KEYSTORE="$CONTRIB"/android_debug.keystore
       -    export P4A_DEBUG_KEYSTORE_PASSWD=unsafepassword
       -    export P4A_DEBUG_KEYALIAS_PASSWD=unsafepassword
       -    export P4A_DEBUG_KEYALIAS=electrum
       -    # create keystore if needed
       -    if [ ! -f "$P4A_DEBUG_KEYSTORE" ]; then
       -        keytool -genkey -v -keystore "$CONTRIB"/android_debug.keystore \
       -            -alias "$P4A_DEBUG_KEYALIAS" -keyalg RSA -keysize 2048 -validity 10000 \
       -            -dname "CN=mqttserver.ibm.com, OU=ID, O=IBM, L=Hursley, S=Hants, C=GB" \
       -            -storepass "$P4A_DEBUG_KEYSTORE_PASSWD" \
       -            -keypass "$P4A_DEBUG_KEYALIAS_PASSWD"
       -    fi
       -    # build two apks (only one on Travis CI)
       -    export APP_ANDROID_ARCH=armeabi-v7a
       -    make apk
       -    if [ ! $CI ]; then
       -        export APP_ANDROID_ARCH=arm64-v8a
       -        make apk
       -    fi
       -fi
       -
       -popd
   DIR diff --git a/electrum/gui/kivy/Makefile b/electrum/gui/kivy/Makefile
       t@@ -1,33 +0,0 @@
       -PYTHON = python3
       -
       -# needs kivy installed or in PYTHONPATH
       -
       -.PHONY: theming apk clean
       -
       -theming:
       -        #bash -c 'for i in network lightning; do convert -background none theming/light/$i.{svg,png}; done'
       -        $(PYTHON) -m kivy.atlas theming/light 1024 theming/light/*.png
       -prepare:
       -        # running pre build setup
       -        @cp tools/buildozer.spec ../../../buildozer.spec
       -        # copy electrum to main.py
       -        @cp ../../../run_electrum ../../../main.py
       -        @-if [ ! -d "../../../.buildozer" ];then \
       -                cd ../../..; buildozer android debug;\
       -                cp -f electrum/gui/kivy/tools/blacklist.txt .buildozer/android/platform/python-for-android/src/blacklist.txt;\
       -                rm -rf ./.buildozer/android/platform/python-for-android/dist;\
       -        fi
       -apk:
       -        @make prepare
       -        @-cd ../../..; buildozer android debug deploy run
       -        @make clean
       -release:
       -        @make prepare
       -        @-cd ../../..; buildozer android release
       -        @make clean
       -clean:
       -        # Cleaning up
       -        # rename main.py to electrum
       -        @-rm ../../../main.py
       -        # remove buildozer.spec
       -        @-rm ../../../buildozer.spec
   DIR diff --git a/electrum/gui/kivy/Readme.md b/electrum/gui/kivy/Readme.md
       t@@ -1,127 +0,0 @@
       -# Kivy GUI
       -
       -The Kivy GUI is used with Electrum on Android devices.
       -To generate an APK file, follow these instructions.
       -
       -## Android binary with Docker
       -
       -✗ _This script does not produce reproducible output (yet!).
       -   Please help us remedy this._
       -
       -This assumes an Ubuntu (x86_64) host, but it should not be too hard to adapt to another
       -similar system. The docker commands should be executed in the project's root
       -folder.
       -
       -1. Install Docker
       -
       -    ```
       -    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
       -    $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
       -    $ sudo apt-get update
       -    $ sudo apt-get install -y docker-ce
       -    ```
       -
       -2. Build image
       -
       -    ```
       -    $ sudo docker build -t electrum-android-builder-img electrum/gui/kivy/tools
       -    ```
       -
       -3. Build locale files
       -
       -    ```
       -    $ ./contrib/pull_locale
       -    ```
       -
       -4. Prepare pure python dependencies
       -
       -    ```
       -    $ ./contrib/make_packages
       -    ```
       -
       -5. Build binaries
       -
       -    ```
       -    $ mkdir --parents $PWD/.buildozer/.gradle
       -    $ sudo docker run -it --rm \
       -        --name electrum-android-builder-cont \
       -        -v $PWD:/home/user/wspace/electrum \
       -        -v $PWD/.buildozer/.gradle:/home/user/.gradle \
       -        -v ~/.keystore:/home/user/.keystore \
       -        --workdir /home/user/wspace/electrum \
       -        electrum-android-builder-img \
       -        ./contrib/make_apk
       -    ```
       -    This mounts the project dir inside the container,
       -    and so the modifications will affect it, e.g. `.buildozer` folder
       -    will be created.
       -
       -5. The generated binary is in `./bin`.
       -
       -
       -
       -## FAQ
       -
       -### I changed something but I don't see any differences on the phone. What did I do wrong?
       -You probably need to clear the cache: `rm -rf .buildozer/android/platform/build/{build,dists}`
       -
       -
       -### How do I deploy on connected phone for quick testing?
       -Assuming `adb` is installed:
       -```
       -$ adb -d install -r bin/Electrum-*-arm64-v8a-debug.apk
       -$ adb shell monkey -p org.electrum.electrum 1
       -```
       -
       -
       -### How do I get an interactive shell inside docker?
       -```
       -$ sudo docker run -it --rm \
       -    -v $PWD:/home/user/wspace/electrum \
       -    -v $PWD/.buildozer/.gradle:/home/user/.gradle \
       -    --workdir /home/user/wspace/electrum \
       -    electrum-android-builder-img
       -```
       -
       -
       -### How do I get more verbose logs for the build?
       -See `log_level` in `buildozer.spec`
       -
       -
       -### How can I see logs at runtime?
       -This should work OK for most scenarios:
       -```
       -adb logcat | grep python
       -```
       -Better `grep` but fragile because of `cut`:
       -```
       -adb logcat | grep -F "`adb shell ps | grep org.electrum.electrum | cut -c14-19`"
       -```
       -
       -
       -### Kivy can be run directly on Linux Desktop. How?
       -Install Kivy.
       -
       -Build atlas: `(cd electrum/gui/kivy/; make theming)`
       -
       -Run electrum with the `-g` switch: `electrum -g kivy`
       -
       -### debug vs release build
       -If you just follow the instructions above, you will build the apk
       -in debug mode. The most notable difference is that the apk will be
       -signed using a debug keystore. If you are planning to upload
       -what you build to e.g. the Play Store, you should create your own
       -keystore, back it up safely, and run `./contrib/make_apk release`.
       -
       -See e.g. [kivy wiki](https://github.com/kivy/kivy/wiki/Creating-a-Release-APK)
       -and [android dev docs](https://developer.android.com/studio/build/building-cmdline#sign_cmdline).
       -
       -### Access datadir on Android from desktop (e.g. to copy wallet file)
       -Note that this only works for debug builds! Otherwise the security model
       -of Android does not let you access the internal storage of an app without root.
       -(See [this](https://stackoverflow.com/q/9017073))
       -```
       -$ adb shell
       -$ run-as org.electrum.electrum ls /data/data/org.electrum.electrum/files/data
       -$ run-as org.electrum.electrum cp /data/data/org.electrum.electrum/files/data/wallets/my_wallet /sdcard/some_path/my_wallet
       -```
   DIR diff --git a/electrum/gui/kivy/tools/buildozer.spec b/electrum/gui/kivy/tools/buildozer.spec
       t@@ -1,226 +0,0 @@
       -[app]
       -
       -# (str) Title of your application
       -title = Electrum
       -
       -# (str) Package name
       -package.name = Electrum
       -
       -# (str) Package domain (needed for android/ios packaging)
       -package.domain = org.electrum
       -
       -# (str) Source code where the main.py live
       -source.dir = .
       -
       -# (list) Source files to include (let empty to include all the files)
       -source.include_exts = py,png,jpg,kv,atlas,ttf,txt,gif,pem,mo,vs,fs,json,csv
       -
       -# (list) Source files to exclude (let empty to not exclude anything)
       -source.exclude_exts = spec
       -
       -# (list) List of directory to exclude (let empty to not exclude anything)
       -source.exclude_dirs = bin, build, dist, contrib,
       -    electrum/tests,
       -    electrum/gui/qt,
       -    electrum/gui/kivy/tools,
       -    electrum/gui/kivy/theming/light
       -# (list) List of exclusions using pattern matching
       -source.exclude_patterns = Makefile,setup*
       -
       -# (str) Application versioning (method 1)
       -version.regex = APK_VERSION = '(.*)'
       -version.filename = %(source.dir)s/electrum/version.py
       -
       -# (str) Application versioning (method 2)
       -#version = 1.9.8
       -
       -# (list) Application requirements
       -requirements =
       -    # note: re python3.8, see #6147
       -    hostpython3==3.7.7,
       -    python3==3.7.7,
       -    android,
       -    openssl,
       -    plyer,
       -    # kivy 1.11.1
       -    kivy==39c17457bae91baf8fe710dc989791e45879f136,
       -    libffi,
       -    libsecp256k1,
       -    cryptography
       -
       -# (str) Presplash of the application
       -#presplash.filename = %(source.dir)s/gui/kivy/theming/splash.png
       -presplash.filename = %(source.dir)s/electrum/gui/icons/electrum_presplash.png
       -
       -# (str) Icon of the application
       -icon.filename = %(source.dir)s/electrum/gui/icons/electrum_launcher.png
       -
       -# (str) Supported orientation (one of landscape, portrait or all)
       -orientation = portrait
       -
       -# (bool) Indicate if the application should be fullscreen or not
       -fullscreen = False
       -
       -
       -#
       -# Android specific
       -#
       -
       -# (list) Permissions
       -android.permissions = INTERNET, CAMERA, WRITE_EXTERNAL_STORAGE
       -
       -# (int) Android API to use
       -android.api = 28
       -
       -# (int) Minimum API required. You will need to set the android.ndk_api to be as low as this value.
       -android.minapi = 21
       -
       -# (str) Android NDK version to use
       -android.ndk = 19c
       -
       -# (int) Android NDK API to use (optional). This is the minimum API your app will support.
       -android.ndk_api = 21
       -
       -# (bool) Use --private data storage (True) or --dir public storage (False)
       -android.private_storage = True
       -
       -# (str) Android NDK directory (if empty, it will be automatically downloaded.)
       -android.ndk_path = /opt/android/android-ndk
       -
       -# (str) Android SDK directory (if empty, it will be automatically downloaded.)
       -android.sdk_path = /opt/android/android-sdk
       -
       -# (str) ANT directory (if empty, it will be automatically downloaded.)
       -android.ant_path = /opt/android/apache-ant
       -
       -# (str) Android entry point, default is ok for Kivy-based app
       -#android.entrypoint = org.renpy.android.PythonActivity
       -
       -# (list) List of Java .jar files to add to the libs so that pyjnius can access
       -# their classes. Don't add jars that you do not need, since extra jars can slow
       -# down the build process. Allows wildcards matching, for example:
       -# OUYA-ODK/libs/*.jar
       -#android.add_jars = foo.jar,bar.jar,path/to/more/*.jar
       -#android.add_jars = lib/android/zbar.jar
       -
       -# (list) List of Java files to add to the android project (can be java or a
       -# directory containing the files)
       -android.add_src = electrum/gui/kivy/data/java-classes/
       -
       -android.gradle_dependencies = me.dm7.barcodescanner:zxing:1.9.8
       -
       -android.add_activities = org.electrum.qr.SimpleScannerActivity
       -
       -# (str) python-for-android branch to use, if not master, useful to try
       -# not yet merged features.
       -#android.branch = master
       -
       -# (str) OUYA Console category. Should be one of GAME or APP
       -# If you leave this blank, OUYA support will not be enabled
       -#android.ouya.category = GAME
       -
       -# (str) Filename of OUYA Console icon. It must be a 732x412 png image.
       -#android.ouya.icon.filename = %(source.dir)s/data/ouya_icon.png
       -
       -# (str) XML file to include as an intent filters in <activity> tag
       -android.manifest.intent_filters = electrum/gui/kivy/tools/bitcoin_intent.xml
       -
       -# (str) launchMode to set for the main activity
       -android.manifest.launch_mode = singleTask
       -
       -# (list) Android additionnal libraries to copy into libs/armeabi
       -#android.add_libs_armeabi = lib/android/*.so
       -
       -# (bool) Indicate whether the screen should stay on
       -# Don't forget to add the WAKE_LOCK permission if you set this to True
       -#android.wakelock = False
       -
       -# (str) The Android arch to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
       -# note: can be overwritten by APP_ANDROID_ARCH env var
       -android.arch = armeabi-v7a
       -
       -# (list) Android application meta-data to set (key=value format)
       -#android.meta_data =
       -
       -# (list) Android library project to add (will be added in the
       -# project.properties automatically.)
       -#android.library_references =
       -
       -android.whitelist = lib-dynload/_csv.so
       -
       -
       -#
       -# Python for android (p4a) specific
       -#
       -
       -# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
       -p4a.source_dir = /opt/python-for-android
       -
       -# (str) The directory in which python-for-android should look for your own build recipes (if any)
       -#p4a.local_recipes =
       -
       -# (str) Filename to the hook for p4a
       -#p4a.hook =
       -
       -# (str) Bootstrap to use for android builds
       -# p4a.bootstrap = sdl2
       -
       -# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
       -#p4a.port =
       -
       -
       -#
       -# iOS specific
       -#
       -
       -# (str) Name of the certificate to use for signing the debug version
       -# Get a list of available identities: buildozer ios list_identities
       -#ios.codesign.debug = "iPhone Developer: <lastname> <firstname> (<hexstring>)"
       -
       -# (str) Name of the certificate to use for signing the release version
       -#ios.codesign.release = %(ios.codesign.debug)s
       -
       -
       -
       -[buildozer]
       -
       -# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
       -log_level = 1
       -
       -
       -# -----------------------------------------------------------------------------
       -# List as sections
       -#
       -# You can define all the "list" as [section:key].
       -# Each line will be considered as a option to the list.
       -# Let's take [app] / source.exclude_patterns.
       -# Instead of doing:
       -#
       -#     [app]
       -#     source.exclude_patterns = license,data/audio/*.wav,data/images/original/*
       -#
       -# This can be translated into:
       -#
       -#     [app:source.exclude_patterns]
       -#     license
       -#     data/audio/*.wav
       -#     data/images/original/*
       -#
       -
       -# -----------------------------------------------------------------------------
       -# Profiles
       -#
       -# You can extend section / key with a profile
       -# For example, you want to deploy a demo version of your application without
       -# HD content. You could first change the title to add "(demo)" in the name
       -# and extend the excluded directories to remove the HD content.
       -#
       -#     [app@demo]
       -#     title = My Application (demo)
       -#
       -#     [app:source.exclude_patterns@demo]
       -#     images/hd/*
       -#
       -# Then, invoke the command line with the "demo" profile:
       -#
       -#     buildozer --profile demo android debug