Skip to content
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

Build failures, how to compile the app in linux container? #16

Closed
emanuelb opened this issue Mar 24, 2021 · 4 comments
Closed

Build failures, how to compile the app in linux container? #16

emanuelb opened this issue Mar 24, 2021 · 4 comments

Comments

@emanuelb
Copy link

Tried to build the latest commit and check if the build is reproducible & if not what the diff are.
Containerfile used is:

FROM frolvlad/alpine-glibc

RUN set -ex; \
    apk update; \
    apk add --no-cache \
        openjdk8 \
        bash \
        git \
        go; \
    adduser -D appuser;

USER appuser

ENV ANDROID_SDK_ROOT="/app/sdk" \
    ANDROID_HOME="/app/sdk"

COPY --chown=appuser:root . /app/munn/

RUN set -ex; \
    ANDROID_SDK_LICENSES="${ANDROID_SDK_ROOT}/licenses"; \
    mkdir -p "${ANDROID_SDK_LICENSES}"; \
    printf "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "${ANDROID_SDK_LICENSES}/android-sdk-license"; \
    cd /app/sdk/; \
    wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip; \
    unzip commandlinetools-linux-6858069_latest.zip; \
    rm commandlinetools-linux-6858069_latest.zip; \
    /app/sdk/cmdline-tools/bin/sdkmanager --sdk_root=/app/sdk/ --install "ndk-bundle"; \
    cd /app/munn/; \
    bash ./tools/bootstrap-gomobile.sh;

ENV PATH="$PATH:/home/appuser/go/bin" \
    ANDROID_NDK_HOME="/app/sdk/ndk/22.0.7026061/"
    
WORKDIR /app/munn/

Run:

git clone https://github.com/muun/apollo --depth 1
cd apollo

Add above Containerfile, Run:

podman build --rm -t munn_build_apk .
podman run --rm --name munn_built_apk -ti munn_build_apk

Then running ./tools/libwallet-android.sh result in error:

/tmp/go-build*****/****/exe/gomobile: open /app/munn/android/apollo/libs/libwallet.aar: no such file or directory
exit status 1

running: (from README.md) GO111MODULE=off go run golang.org/x/mobile/cmd/gomobile bind -target=android -o android/apollo/libs/libwallet.aar github.com/muun/muun/libwallet result in:

cannot find package "golang.org/x/mobile/cmd/gomobile" in any of:
/usr/lib/go/src/golang.org/x/mobile/cmd/gomobile (from $GOROOT)
/home/appuser/go/src/golang.org/x/mobile/cmd/gomobile (from $GOPATH)

So then running go get golang.org/x/mobile/cmd/gomobile and trying above command again, result in error:

/tmp/go-build*****/****/exe/gomobile: /home/appuser/go/bin/gobind -lang=go,java -outdir=/tmp/gomobile-work-612991822 github.com/muun/muun/libwallet failed: exit status 1
no exported names in the package "github.com/muun/muun/libwallet"
no exported names in the package "github.com/muun/muun/libwallet"
no exported names in the package "github.com/muun/muun/libwallet"
no exported names in the package "github.com/muun/muun/libwallet"

also running ./gradlew :android:apollo:assembleProdRelease result in error (from: #12)

Task 'assembleProdRelease' not found in project ':android:apollo'.

but running ./gradlew assembleRelease works, and fail with libwallet error:

* What went wrong:
Could not determine the dependencies of task ':android:apolloui:lintVitalLocalRelease'.
> Could not resolve all artifacts for configuration ':android:apolloui:developmentMinifiedRuntimeClasspath'.
   > Failed to transform libwallet.aar to match attributes {artifactType=jar}.
      > Execution failed for JetifyTransform: /app/munn/android/apollo/libs/libwallet.aar.
         > Failed to transform '/app/munn/android/apollo/libs/libwallet.aar' using Jetifier. Reason: /app/munn/android/apollo/libs/libwallet.aar (No such file or directory). (Run with --stacktrace for more details.)

What is needed in order to compile the app, can you publish a Containerfile/Dockerfile?

@champo
Copy link
Contributor

champo commented Mar 24, 2021

Hi! Thanks for reaching out and the research. We're really close to officially supporting reproducible builds, our next release will include it. It will include better instructions and a Dockerfile for easier building.

(Disclaimer: I haven't run your steps, but the errors look eerily similar to the ones I had when crafting the Dockerfile)

  1. I think you need to make sure to mkdir -p android/apollo/libs before running ./tools/libwallet-android.sh.
  2. Should be :android:apolloui:assembleProdRelease. Thanks for finding this error!
  3. The other error should be fixed after 1., it's caused by the failures to build the lib.

@champo
Copy link
Contributor

champo commented Mar 24, 2021

BTW, the release should be in the next few days! If you have any feedback once it's out I'd love to hear it.

@emanuelb
Copy link
Author

Thanks, it's kinda worked, shame that I didn't try the mkdir -p before posting this issue, anyway it returned:

rebuilt gomobile with status 0 to /app/munn/android/apollo/libs/libwallet.aar

and then ./gradlew :android:apolloui:assembleProdRelease command failed with:

> > Task :android:apollo:libwallet
rebuilt gomobile with status 0 to /app/munn/android/apollo/libs/libwallet.aar

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':android:apolloui:checkProdReleaseDuplicateClasses'.
> Could not resolve all files for configuration ':android:apolloui:prodReleaseRuntimeClasspath'.
   > Failed to transform libwallet.aar to match attributes {artifactType=android-classes, org.gradle.usage=java-runtime}.
      > Execution failed for AarToClassTransform: /home/appuser/.gradle/caches/transforms-2/files-2.1/0f995b8c08717c0d0c5400dafd9d97fd/jetified-libwallet.aar.
         > zip file is empty

but ./gradlew assembleRelease worked! with lots of warnings, some are mostly errors, like:

Task :android:apollo:bundleReleaseAar
WARNING: The AAR produced by this build for the :android:apollo project is broken. Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR is broken because the classes and Android resources from any local .aar file dependencies are not packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not having this warning), and this warning will be replaced with an error in subsequent versions of the Android Gradle Plugin. The following direct local .aar file dependencies caused this warning: /app/munn/android/apollo/libs/libwallet.aar

and many many other warnings, which you should take a look at if they happen on the soon to be released version. The resulted APK is not reproducible (diffs in PNG files & resources.arsc & classes.dex & classes2.dex)
Will test the upcoming release when it will be available :)

@emanuelb
Copy link
Author

There is now Dockerfile in ./apollo/android/Dockerfile and I used below Containerfile to compile version 45.1:

FROM frolvlad/alpine-glibc

RUN set -ex; \
    apk update; \
    apk add --no-cache \
        openjdk11 \
        bash \
        git \
        go; \
    adduser -D appuser;

USER appuser

ENV ANDROID_SDK_ROOT="/app/sdk" \
    ANDROID_HOME="/app/sdk"
    
COPY --chown=appuser:root . /app/munn/

RUN set -ex; \
    mkdir -p "/app/sdk/licenses"; \
    printf "\n24333f8a63b6825ea9c5514f83c2829b004d1fee" > "/app/sdk/licenses/android-sdk-license"; \
    cd /app/sdk/; \
    wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip; \
    unzip commandlinetools-linux-6858069_latest.zip; \
    rm commandlinetools-linux-6858069_latest.zip; \
    /app/sdk/cmdline-tools/bin/sdkmanager --sdk_root=/app/sdk/ --install "ndk-bundle" "platforms;android-28";
    
WORKDIR /app/munn/
ENV ANDROID_NDK_HOME="/app/sdk/ndk/22.0.7026061/" \
    PATH="$PATH:/usr/lib/jvm/java-11-openjdk/bin/:/home/appuser/go/bin"

RUN set -ex; \
    mkdir -p /app/munn/android/apollo/libs; \
    ./tools/bootstrap-gomobile.sh; \
    ./tools/libwallet-android.sh; \
    ./gradlew :android:apollo:libwallet; \
    ./gradlew :android:apolloui:assembleProdRelease;

APK file will be in: /app/munn/android/apolloui/build/outputs/apk/prod/release/apolloui-prod-release-unsigned.apk
so closing this issue as it's solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants