Building for F-Droid and adding an app to the F-Droid store
2019-07-12
How to build an android app for fdroid using WSL Ubuntu on Windows 10
I started with the official description, which tells us to first follow the fdroid quickstart
Install fdroidserver (I had #da0d639)
git clone https://gitlab.com/fdroid/fdroidserver.git
export PATH="$PATH:$PWD/fdroidserver"
# link it to the bin folder so it will be found
sudo ln -s $(pwd)/fdroidserver/fdroid /usr/binCheck out fdroid data (I had #03e4a06)
git clone https://gitlab.com/fdroid/fdroiddata.git
cd fdroiddataMake sure fdroid works and reads the metadata files properly:
fdroid readmetaCreate config.py and key store
Optionally create a base config.py and signing keys with:
fdroid initWhich fails with this error:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/doc/fdroidserver/examples/fdroid-icon.png'Fix: link examples from fdroidserver to doc
sudo mkdir /usr/share/doc/fdroidserver
sudo ln -s $(pwd)/../fdroidserver/examples /usr/share/doc/fdroidserverTry again
$ fdroid init
INFO: Generating a new key in "keystore.jks"...
[...]
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.jks -deststoretype pkcs12".
INFO:
Built repo based in "/home/marc/fdroiddata" with this config:
Android SDK: /home/marc/android
Android NDK r12b (optional): $ANDROID_NDK
Keystore for signing key: keystore.jks
To complete the setup, add your APKs to "/home/marc/fdroiddata/repo"
then run "fdroid update -c; fdroid update". You might also want to edit
"config.py" to set the URL, repo name, and more. You should also set up
a signing key (a temporary one might have been automatically generated).
For more info: https://f-droid.org/docs/Setup_an_F-Droid_App_Repo
and https://f-droid.org/docs/Signing_ProcessAdd the new app
fdroid import --url https://github.com/marc136/tonuino-nfc-tools --subdir appchange the generated metadata, get inspiration from e.g. templates/app-full or on gitlab.
# fill automated fields like Auto Name
fdroid checkupdates de.mw136.tonuino
# manual changes
vim metadata/de.mw136.tonuino.yml
# check if entered data is valid
fdroid readmeta
# check of warnings or errors
fdroid lint de.mw136.tonuino
# let a tool do formatting
fdroid rewritemeta de.mw136.tonuinoExample content
Categories:
- Development
- Science & Education
License: BSD-3-Clause
SourceCode: https://github.com/marc136/tonuino-nfc-tools
IssueTracker: https://github.com/marc136/tonuino-nfc-tools/issues
Summary: Read and write NFC tags for the TonUINO music box
Description: |-
This app will only work if the device supports NFC.
More information about the TonUINO diy music box is available at https://www.tonuino.de
RepoType: git
Repo: https://github.com/marc136/tonuino-nfc-tools
Builds:
- versionName: 0.3.1
versionCode: 6
commit: v0.3.1
subdir: app
gradle:
- yes
AutoUpdateMode: None
UpdateCheckMode: TagsBuild the new app
Following the official contributing guide.
fdroid build -v -l de.mw136.tonuinoNote: This fails if no android SDK exists
Install the Android SDK (and sdkmanager)
Download command line tools.
mkdir ~/android
cd ~/android
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
# install unzip if needed
# sudo apt install unzip
unzip sdk-tools-linux-4333796.zipAdd to .profile (or .bashrc or the like)
export ANDROID_HOME=$PWD
export PATH="$PATH:$ANDROID_HOME/tools/bin"Then use sdkmanager to install build-tools in the correct version and platform-tools.
sdkmanager --install "build-tools;29.0.0" platform-tools
# not run myself, will be done by fdroid
# sdkmanager --install "platforms;android-28"
# update the installed tools
sdkmanager --updateThis throws an error
Warning: File /home/xxxx/.android/repositories.cfg could not be loaded.Fix: Just create the missing file: (see post)
touch ~/.android/repositories.cfgThen continue
# update the installed tools
sdkmanager --updateBuild the new app
fdroid build -v -l de.mw136.tonuinoI had this problem, but we already linked the bin folder above so it should not happen:
ERROR: Could not build app de.mw136.tonuino: OSError while trying to execute /usr/lib/python3/dist-packages/gradlew-fdroid clean: [Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/gradlew-fdroid'Info: https://forum.f-droid.org/t/build-error-gradlew-fdroid-no-such-file/5601/4
Fix: Link it to the bin folder
sudo ln -s $(pwd)/fdroidserver/fdroid /usr/binBuild succeeds, but cannot get installed because the app is not yet signed.
Using adb, we can see more information
adb install tonuino-nfc-tools.apkReturns
Performing Streamed Install
adb: failed to install tonuino-nfc-tools.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Package /data/app/vmdl860694333.tmp/base.apk has no certificates at entry AndroidManifest.xml]Creating a signed build
To get a signed version for testing, use fdroid publish which will sign the built .apk and move it from the folder unsigned to repo.
Or use fdroid install to immediately deploy it to a connected emulator or device.
More info on these commands are on this page.
Now I could commit my changes on fdroiddata/metadata/de.mw136.tonuino. to the fdroiddata repository and a day after it was merged, it would show up in fdroid.
But I want to have the same information as in the Google Play Store, so I will try to configured fastlane next (as described in this post).
Configure auto-building
Configure auto-building (explanation is here, but this picks up tags like v1.0.0).
AutoUpdateMode: Version v%v
UpdateCheckMode: Tags