From 8ff0e1da1578d4dea5b89227eca4ade39943c871 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 18 Feb 2024 15:23:37 +0100 Subject: [PATCH] Amend Android dev documentation --- android/app/build.gradle | 4 +++ doc/developing/README.md | 1 + doc/developing/android.md | 63 +++++++++++++++++++++++++++++++++++++++ doc/developing/misc.md | 46 ---------------------------- 4 files changed, 68 insertions(+), 46 deletions(-) create mode 100644 doc/developing/android.md diff --git a/android/app/build.gradle b/android/app/build.gradle index 6bacc3d55..c7471d2c7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -108,6 +108,10 @@ task prepareAssets() { preBuild.dependsOn zipAssets prepareAssets.dependsOn ':native:getDeps' +clean { + delete new File("src/main/assets", "Minetest.zip") +} + // Map for the version code that gives each ABI a value. import com.android.build.OutputFile diff --git a/doc/developing/README.md b/doc/developing/README.md index b12e75ce4..d15ab8f69 100644 --- a/doc/developing/README.md +++ b/doc/developing/README.md @@ -15,6 +15,7 @@ Notable pages: ## In this folder - [Developing minetestserver with Docker](docker.md) +- [Android tips & tricks](android.md) - [Miscellaneous](misc.md) ## IRC diff --git a/doc/developing/android.md b/doc/developing/android.md new file mode 100644 index 000000000..e278c48d8 --- /dev/null +++ b/doc/developing/android.md @@ -0,0 +1,63 @@ +# Android tips & tricks + +## Sign the Android APK from CI + +The [Github Actions Workflow](https://github.com/minetest/minetest/actions?query=workflow%3Aandroid+event%3Apush) +automatically produces an APK for each architecture. +Before installing them onto a device they however need to be signed. + +This requires an installation of the Android SDK and `adb`. +```bash +.../android-sdk/build-tools/30.0.3/apksigner sign --ks ~/.android/debug.keystore \ + app-arm64-v8a-release-unsigned.apk +# Enter 'android' (without quotes) when asked for a password +``` + +Note that the `debug.keystore` will not exist if you have never compiled an +Android app on your system (probably). + +After that installing it will work: +```bash +adb install -r -d ./app-arm64-v8a-release-unsigned.apk +``` + +## How to get debug output from Minetest on Android + +In case debug.txt isn't enough (e.g. when debugging a crash), you can get debug +output using logcat: + +`adb logcat -s 'Minetest:*' '*:F'` + +Note that you can do this even *after* the app has crashed, +since Android keeps an internal buffer. + +A segmentation fault for example looks like this: + +``` +01-10 17:20:22.215 19308 20560 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 20560 (MinetestNativeT), pid 19308 (netest.minetest) +01-10 17:20:22.287 20576 20576 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** +01-10 17:20:22.287 20576 20576 F DEBUG : Build fingerprint: '...' +01-10 17:20:22.287 20576 20576 F DEBUG : Revision: '4' +01-10 17:20:22.287 20576 20576 F DEBUG : ABI: 'arm64' +01-10 17:20:22.288 20576 20576 F DEBUG : Timestamp: 2024-01-10 17:20:22+0100 +01-10 17:20:22.288 20576 20576 F DEBUG : pid: 19308, tid: 20560, name: MinetestNativeT >>> net.minetest.minetest <<< +01-10 17:20:22.288 20576 20576 F DEBUG : uid: 10385 +01-10 17:20:22.288 20576 20576 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- +[ ... more information follows ... ] +``` + +If you want get rid of previous output you can do that with `adb logcat -c`. + +## I edited builtin, shaders, ... but nothing changed. Help! + +You're probably hitting two problems: +* the build system only generates assets once +* the app only re-extracts assets when the version changes + +Force regenerating the assets: `./gradlew app:clean` + +Erase the app's memory of which version was installed: `adb shell run-as net.minetest.minetest rm shared_prefs/MinetestSettings.xml` + +If this doesn't work you can also uninstall it using `adb shell pm uninstall net.minetest.minetest`. You will obviously lose your data. + +Then build and install as normal and your changes should be applied. diff --git a/doc/developing/misc.md b/doc/developing/misc.md index a48ed2237..dfecd031d 100644 --- a/doc/developing/misc.md +++ b/doc/developing/misc.md @@ -1,51 +1,5 @@ # Miscellaneous -## Sign the Android APK from CI - -The [Github Actions Workflow](https://github.com/minetest/minetest/actions?query=workflow%3Aandroid+event%3Apush) -automatically produces an APK for each architecture. -Before installing them onto a device they however need to be signed. - -This requires an installation of the Android SDK and `adb`. -```bash -.../android-sdk/build-tools/30.0.3/apksigner sign --ks ~/.android/debug.keystore \ - app-arm64-v8a-release-unsigned.apk -# Enter 'android' (without quotes) when asked for a password -``` - -Note that the `debug.keystore` will not exist if you have never compiled an -Android app on your system (probably). - -After that installing it will work: -```bash -adb install -r -d ./app-arm64-v8a-release-unsigned.apk -``` - -## How to get debug output from Minetest on Android - -In case debug.txt isn't enough (e.g. when debugging a crash), you can get debug -output using logcat: - -`adb logcat -s 'Minetest:*' '*:F'` - -Note that you can do this even *after* the app has crashed, -since Android keeps an internal buffer. - -A segmentation fault for example looks like this: - -``` -01-10 17:20:22.215 19308 20560 F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 20560 (MinetestNativeT), pid 19308 (netest.minetest) -01-10 17:20:22.287 20576 20576 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** -01-10 17:20:22.287 20576 20576 F DEBUG : Build fingerprint: '...' -01-10 17:20:22.287 20576 20576 F DEBUG : Revision: '4' -01-10 17:20:22.287 20576 20576 F DEBUG : ABI: 'arm64' -01-10 17:20:22.288 20576 20576 F DEBUG : Timestamp: 2024-01-10 17:20:22+0100 -01-10 17:20:22.288 20576 20576 F DEBUG : pid: 19308, tid: 20560, name: MinetestNativeT >>> net.minetest.minetest <<< -01-10 17:20:22.288 20576 20576 F DEBUG : uid: 10385 -01-10 17:20:22.288 20576 20576 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr -------- -[ ... more information follows ... ] -``` - ## Profiling Minetest on Linux We will be using a tool called "perf", which you can get by installing `perf` or `linux-perf` or `linux-tools-common`.