From baa02936207e5fdfbad446bf635d5d032f7cb398 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 27 Jun 2019 07:08:03 +0200 Subject: [PATCH] android build: persist debug keystore so that we can upgrade debug installations on the phone and keep the datadir --- .gitignore | 1 + contrib/make_apk | 11 +++++++++++ electrum/gui/kivy/Readme.md | 23 ++++++++++++++++++++++- electrum/gui/kivy/tools/Dockerfile | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 84d5565c9..f5985cac9 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ contrib/build-wine/tmp/ contrib/build-wine/fresh_clone/ contrib/build-linux/appimage/build/ contrib/build-linux/appimage/.cache/ +contrib/android_debug.keystore diff --git a/contrib/make_apk b/contrib/make_apk index f6d691876..115b28ee9 100755 --- a/contrib/make_apk +++ b/contrib/make_apk @@ -30,6 +30,17 @@ if [[ -n "$1" && "$1" == "release" ]] ; then export P4A_RELEASE_KEYALIAS=electrum 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 + 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 make apk fi diff --git a/electrum/gui/kivy/Readme.md b/electrum/gui/kivy/Readme.md index 887d7899f..f0b4b52cd 100644 --- a/electrum/gui/kivy/Readme.md +++ b/electrum/gui/kivy/Readme.md @@ -81,13 +81,34 @@ $ sudo docker run -it --rm \ ``` -### How do I get more verbose logs? +### 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). diff --git a/electrum/gui/kivy/tools/Dockerfile b/electrum/gui/kivy/tools/Dockerfile index 5e1f55e83..13ec31d41 100644 --- a/electrum/gui/kivy/tools/Dockerfile +++ b/electrum/gui/kivy/tools/Dockerfile @@ -152,6 +152,8 @@ RUN cd /opt \ && git cherry-pick d7f722e4e5d4b3e6f5b1733c95e6a433f78ee570 \ # fix gradle "versionCode" overflow: && git cherry-pick ed20e196fbcdce718a180f88f23bb2d165c4c5d8 \ + # gradle: persist debug keystore: + && git cherry-pick aaa0d5d0e7a334631df71e0a9bf127817e0ab9ab \ && python3 -m pip install --user -e . # build env vars