Skip to content

Commit

Permalink
fix: repair the Android build
Browse files Browse the repository at this point in the history
Rather than hardcoding the NDK version inside a script, encode it
as a file in the filesystem, which is easier to share.

Call ./MOBILE/android/ensure in the github action so we fail if
we cannot install the desired Android NDK version.

Make sure we use the desired NDK by setting environment variables.

Use `-androidabi 21`, which:

1. is what rclone did: rclone/rclone@8390ba4

2. is the minimum ABI used by probe-android: https://github.com/ooni/probe-android/blob/994651be52ff75ee3a00dba499ec7c7b40ab25c1/app/build.gradle#L10

Part of ooni/probe#2130
  • Loading branch information
bassosimone committed Aug 29, 2022
1 parent 9e38ee5 commit c3fbe95
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- "release/**"
- "fullbuild"
- "androidbuild"
tags:
- "v*"

Expand Down Expand Up @@ -34,6 +35,8 @@ jobs:
PSIPHON_CONFIG_KEY: ${{ secrets.PSIPHON_CONFIG_KEY }}
PSIPHON_CONFIG_JSON_AGE_BASE64: ${{ secrets.PSIPHON_CONFIG_JSON_AGE_BASE64 }}
- run: ./MOBILE/android/ensure

- run: make ./MOBILE/android

- run: |
Expand Down
2 changes: 1 addition & 1 deletion MOBILE/android/ensure
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

__install_extra="build-tools;32.0.0 platforms;android-31"

__ndk_version="23.1.7779620"
__ndk_version=$(cat ./NDKVERSION)

ANDROID_HOME=$(./MOBILE/android/home)

Expand Down
16 changes: 15 additions & 1 deletion MOBILE/gomobile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ else
OONI_PSIPHON_TAGS=""
fi

MAYBE_ANDROID_API=""
if [[ $TARGET == "android" ]]; then
ANDROID_HOME=$(./MOBILE/android/home)
NDK_VERSION=$(cat NDKVERSION)
ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NDK_VERSION
MAYBE_ANDROID_API="-androidapi 21"
fi

PRODUCT=$(basename $PACKAGE)

function cleanup() {
Expand All @@ -51,11 +59,17 @@ function cleanup() {
trap cleanup EXIT

set -x

# for documenting the environ variables used by the build
export ANDROID_HOME=$ANDROID_HOME
export ANDROID_NDK_HOME=$ANDROID_NDK_HOME

go install golang.org/x/mobile/cmd/gomobile@latest
$(go env GOPATH)/bin/gomobile init
# Adding gomobile to go.mod as documented by golang.org/wiki/Mobile
go get -d golang.org/x/mobile/cmd/gomobile

$(go env GOPATH)/bin/gomobile bind -target $TARGET \
-o ./MOBILE/$TARGET/$PRODUCT.$EXT -tags="$OONI_PSIPHON_TAGS" \
-o ./MOBILE/$TARGET/$PRODUCT.$EXT $MAYBE_ANDROID_API \
-tags="$OONI_PSIPHON_TAGS" \
-ldflags '-s -w' ${GOLANG_EXTRA_FLAGS:-} $PACKAGE
1 change: 1 addition & 0 deletions NDKVERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25.1.8937393

0 comments on commit c3fbe95

Please sign in to comment.