Skip to content

openpriv/android-go-mobile update to 2021.03 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ FROM openjdk:8

ENV SDK_URL="https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" \
ANDROID_HOME="/usr/local/android-sdk" \
ANDROID_VERSION=28 \
ANDROID_BUILD_TOOLS_VERSION=28.0.1
ANDROID_SDK=$ANDROID_HOME \
ANDROID_VERSION=29 \
ANDROID_BUILD_TOOLS_VERSION=30.0.2

## Download Android SDK
RUN mkdir "$ANDROID_HOME" .android \
Expand All @@ -23,7 +24,9 @@ RUN $ANDROID_HOME/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSIO
"platform-tools"

# Install NDK
RUN $ANDROID_HOME/tools/bin/sdkmanager "ndk-bundle"
ENV NDK_VER="21.0.6113669"
RUN $ANDROID_HOME/tools/bin/sdkmanager "ndk;$NDK_VER"
RUN ln -sf $ANDROID_HOME/ndk/$NDK_VER $ANDROID_HOME/ndk-bundle

# Go section of this Dockerfile from Docker golang: https://github.com/docker-library/golang/blob/master/1.10/alpine3.8/Dockerfile
# Adapted from alpine apk to debian apt
Expand All @@ -33,7 +36,8 @@ RUN $ANDROID_HOME/tools/bin/sdkmanager "ndk-bundle"
## - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
RUN echo 'hosts: files dns' > /etc/nsswitch.conf

ENV GOLANG_VERSION 1.10.3
ENV GOLANG_VERSION=1.15.10
ENV GOLANG_SHA256=c1dbca6e0910b41d61a95bf9878f6d6e93d15d884c226b91d9d4b1113c10dd65

RUN set -eux; \
apt-get update; \
Expand Down Expand Up @@ -64,7 +68,7 @@ RUN set -eux; \
esac; \
\
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
echo '567b1cc66c9704d1c019c50bef946272e911ec6baf244310f87f4e678be155f2 *go.tgz' | sha256sum -c -; \
echo "$GOLANG_SHA256 *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
Expand All @@ -75,18 +79,26 @@ RUN set -eux; \
go version

# persist new go in PATH
ENV PATH /usr/local/go/bin:$PATH
ENV PATH=/usr/local/go/bin:$PATH

ENV GOMOBILEPATH=/gomobile
# Setup /workspace
RUN mkdir /workspace
RUN mkdir /go
# link $GOPATH to persistent /go
RUN ln -sf /go /workspace/go
RUN mkdir $GOMOBILEPATH
# Set up GOPATH in /workspace
ENV GOPATH /workspace/go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" "$GOPATH/pkg" && chmod -R 777 "$GOPATH"
ENV GOPATH=$GOMOBILEPATH
ENV PATH=$GOMOBILEPATH/bin:$PATH
RUN mkdir -p "$GOMOBILEPATH/src" "$GOMOBILEPATH/bin" "$GOMOBILEPATH/pkg" && chmod -R 777 "$GOMOBILEPATH"

# install gomobile
RUN cd $GOMOBILEPATH/src; \
mkdir -p golang.org/x; \
cd golang.org/x; \
git clone https://github.com/golang/mobile.git; \
cd mobile; \
git checkout bdb1ca9a1e083af5929a8214e8a056d638ebbf2d;

RUN go get golang.org/x/mobile/cmd/gomobile
RUN gomobile init -ndk $ANDROID_HOME/ndk-bundle/
RUN go get golang.org/x/mobile/cmd/gobind
RUN go get golang.org/x/mobile/bind

RUN gomobile clean
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@

This image was built for use with Drone CI but can be used with any docker setup you want.

Versions are:

- 2021.03
- Go 1.15.10
- Android API 29
- NDK 21.0.6113669
- 2018.07
- Go 1.10.3
- Android API 28
- NDK 17.2.4988734

## Install and Use

### Version 2021.03

This image includes:

- Android SDK, NDK, tools, and API version 29 and Buildtools 30.0.2 at `/usr/local/android-sdk`
- Go lang 1.15.10 at `/usr/local/go`
- $GOPATH set to `/gomobile`
- GOPATH includes gomobile cmd tools and source

This container has its own GOPATH with only gomobile in it, so to use, you'll need to re-get your go dependancies and then run `gomobile init`. The following example shows a Drone CI step using this image

gomobile-build:
image: openpriv/android-go-mobile:2021.03
commands:
- go mod download
- gomobile init
- make

### Version 2018.07

This image includes:

- Android SDK, NDK, tools, and API version 28 at `/usr/local/android-sdk`
Expand Down