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

Reproducible Builds #1395

Open
keraliss opened this issue Aug 7, 2024 · 4 comments
Open

Reproducible Builds #1395

keraliss opened this issue Aug 7, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@keraliss
Copy link

keraliss commented Aug 7, 2024

What mobile OS are you using?

Android

Please provide details on the device you experienced the bug on

Hi, i'm Keraliss from walletscrutiny, i tried to build your app from the dockerfile provided in the repository, but it resulted in this error -

BUILD FAILED in 26m 49s
Running Gradle task 'assembleRelease'...                         1609.5s
Gradle task assembleRelease failed with exit code 1
+ '[' '!' -f /tmp/test_com.foundationdevices.envoy/build/app/outputs/flutter-apk/app-release.apk ']'
+ echo 'Error: APK file not found at /tmp/test_com.foundationdevices.envoy/build/app/outputs/flutter-apk/app-release.apk'
Error: APK file not found at /tmp/test_com.foundationdevices.envoy/build/app/outputs/flutter-apk/app-release.apk

Description

As the build from provided dockerfile failed, we created our own dockerfile based on the one provided. This is the dockerfile

# Use Ubuntu 22.04 as the base image
FROM ubuntu:22.04

# Set environment variables
ENV TZ=America/New_York
ENV ANDROID_SDK_ROOT=/root/Android/sdk
ENV PATH="$PATH:/root/Android/sdk/platform-tools:/root/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin:/root/flutter/bin:/root/.cargo/bin"
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages
RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y --no-install-recommends \
    postgresql curl build-essential libssl-dev pkg-config libpq-dev git unzip xz-utils zip \
    libglu1-mesa openjdk-8-jdk openjdk-17-jdk wget python2 autoconf clang cmake ninja-build \
    libgtk-3-0 libgtk-3-dev v4l2loopback-dkms v4l2loopback-utils libzbar-dev libzbar0 \
    libzbargtk-dev libjsoncpp-dev libsecret-1-dev libsecret-1-0 ffmpeg xvfb xdotool x11-utils \
    libstdc++-12-dev llvm-14 libsdl2-dev libclang1-14 libtool sudo libusb-1.0-0-dev \
    python3-virtualenv xorg xdg-user-dirs xterm tesseract-ocr ca-certificates openssl && \
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Update SSL certificates
RUN update-ca-certificates

# Install Android SDK Command-line Tools
RUN update-java-alternatives --set /usr/lib/jvm/java-1.8.0-openjdk-amd64 && \
    mkdir -p /root/Android/sdk /root/.android && \
    touch /root/.android/repositories.cfg && \
    wget -O sdk-tools.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && \
    unzip sdk-tools.zip -d /root/Android/sdk && rm sdk-tools.zip

# Install required Android components
RUN yes | /root/Android/sdk/tools/bin/sdkmanager --licenses && \
    /root/Android/sdk/tools/bin/sdkmanager "build-tools;30.0.3" "platforms;android-30" \
    "platform-tools" "cmdline-tools;latest" "ndk;25.2.9519653"

# Install Flutter SDK
RUN git clone https://github.com/flutter/flutter.git /root/flutter && \
    flutter channel stable && \
    flutter upgrade && \
    flutter config --enable-linux-desktop && \
    flutter precache && \
    flutter doctor

# Configure Cargo to use git-fetch-with-cli and add crates.io mirror
RUN mkdir -p /root/.cargo && \
    echo '[net]' > /root/.cargo/config.toml && \
    echo 'git-fetch-with-cli = true' >> /root/.cargo/config.toml && \
    echo '[source.crates-io]' >> /root/.cargo/config.toml && \
    echo 'replace-with = "tuna"' >> /root/.cargo/config.toml && \
    echo '[source.tuna]' >> /root/.cargo/config.toml && \
    echo 'registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"' >> /root/.cargo/config.toml

# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.69.0 -y && \
    rustup target add aarch64-linux-android

# Clone the repository and set working directory
RUN git clone https://github.com/Foundation-Devices/envoy.git /root/repo
WORKDIR /root/repo

# Copy the build script
COPY build_ffi_android.sh /root/repo/
RUN chmod +x /root/repo/build_ffi_android.sh

# Create a new script to run the build and keep the container running
RUN echo '#!/bin/bash' > /root/build_and_keep_running.sh && \
    echo 'cd /root/repo' >> /root/build_and_keep_running.sh && \
    echo 'pkill -f cargo' >> /root/build_and_keep_running.sh && \
    echo 'rm -f /root/.cargo/.package-cache' >> /root/build_and_keep_running.sh && \
    echo './build_ffi_android.sh || {' >> /root/build_and_keep_running.sh && \
    echo '    echo "Build failed, attempting to clean and rebuild..."' >> /root/build_and_keep_running.sh && \
    echo '    cargo clean' >> /root/build_and_keep_running.sh && \
    echo '    cargo build --target=aarch64-linux-android' >> /root/build_and_keep_running.sh && \
    echo '    cargo build --target=aarch64-linux-android --release' >> /root/build_and_keep_running.sh && \
    echo '    flutter pub get' >> /root/build_and_keep_running.sh && \
    echo '    flutter build apk --release' >> /root/build_and_keep_running.sh && \
    echo '}' >> /root/build_and_keep_running.sh && \
    echo 'echo "Build process completed. Checking for APK..."' >> /root/build_and_keep_running.sh && \
    echo 'find /root/repo -name "*.apk"' >> /root/build_and_keep_running.sh && \
    echo 'echo "Versions of tools:"' >> /root/build_and_keep_running.sh && \
    echo 'cargo --version' >> /root/build_and_keep_running.sh && \
    echo 'rustc --version' >> /root/build_and_keep_running.sh && \
    echo 'flutter --version' >> /root/build_and_keep_running.sh && \
    echo 'tail -f /dev/null' >> /root/build_and_keep_running.sh && \
    chmod +x /root/build_and_keep_running.sh

# Set the new script as the CMD
CMD ["/root/build_and_keep_running.sh"]

And this is the com.foundationdevices.envoy.build_ffi_android.sh file

#!/bin/bash
set -e

# Function to log messages
log_message() {
    echo "$(date '+%Y-%m-%d %H:%M:%S') - $1"
}

# Build Rust libraries
log_message "Starting Rust build for aarch64-linux-android"
cargo +1.69.0 build --target=aarch64-linux-android
cargo +1.69.0 build --target=aarch64-linux-android --release

# Get Flutter dependencies
log_message "Getting Flutter dependencies"
flutter pub get

# Build the APK
log_message "Building APK"
flutter build apk --release

# Check if APK was built successfully
APK_PATH="/root/repo/build/app/outputs/flutter-apk/app-release.apk"
if [ -f "$APK_PATH" ]; then
    log_message "Build completed successfully. APK is at $APK_PATH"
else
    log_message "ERROR: APK not found at $APK_PATH"
    exit 1
fi

# Print versions for debugging
log_message "Tool versions:"
cargo --version
rustc --version
flutter --version

Please provide the steps that you've used to reproduce the issue

Docker Build and Run Commands:

docker build -t envoy_wallet -f envoy.dockerfile .

the build was successful

Successfully built 67097ce5b7b9
Successfully tagged envoy_wallet:latest

Then we tried to run the container

docker run -d --name envoy_build_container_new envoy_wallet

And got this

Error building OpenSSL:
   Command: cd "/root/repo/target/aarch64-linux-android/release/build/openssl-sys-9f47e4e5d09d2dda/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=6,7 --jobserver-auth=6,7" "make" "build_libs"
   Exit status: exit status: 2


   , /root/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/openssl-src-300.2.1+3.2.0/src/lib.rs:611:9
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   Resolving dependencies... (23.0s)
   Note: intl is pinned to version 0.19.0 by flutter_localizations from the flutter SDK.
   See https://dart.dev/go/sdk-version-pinning for details.


   Because envoy depends on flutter_localizations from sdk which depends on intl 0.19.0, intl 0.19.0 is required.
   So, because envoy depends on intl ^0.18.0, version solving failed.
   Resolving dependencies... (4.8s)
   Note: intl is pinned to version 0.19.0 by flutter_localizations from the flutter SDK.
   See https://dart.dev/go/sdk-version-pinning for details.


   Because envoy depends on flutter_localizations from sdk which depends on intl 0.19.0, intl 0.19.0 is required.
   So, because envoy depends on intl ^0.18.0, version solving failed.
   Build process completed. Checking for APK...
   Versions of tools:
   cargo 1.69.0 (6e9a83356 2023-04-12)
   rustc 1.69.0 (84c898d65 2023-04-16)
   Flutter 3.24.0 • channel stable • https://github.com/flutter/flutter.git
   Framework • revision 80c2e84975 (8 days ago) • 2024-07-30 23:06:49 +0700
   Engine • revision b8800d88be
   Tools • Dart 3.5.0 • DevTools 2.37.2

If applicable, add screenshots or screen recordings to help explain the issue.

No response

If applicable, add logs to help us diagnose the issue.

No response

Anything else?

Issues Encountered:

  1. OpenSSL Build Failure:
    The build process for OpenSSL failed with the following error:

    Error building OpenSSL:
    Command: cd "/root/repo/target/aarch64-linux-android/release/build/openssl-sys-9f47e4e5d09d2dda/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=6,7 --jobserver-auth=6,7" "make" "build_libs"
    Exit status: exit status: 2
    

    This indicates potential issues with missing tools or incorrect configuration for building OpenSSL.

  2. Flutter Dependency Conflict:
    There is a version conflict with the intl package. The project specifies intl ^0.18.0, but the Flutter SDK requires intl 0.19.0 due to dependencies like flutter_localizations. This conflict prevents the successful build of the APK. The specific error encountered was:

    Error resolving dependencies:
    Because envoy depends on flutter_localizations from sdk which depends on intl 0.19.0, intl 0.19.0 is required.
    So, because envoy depends on intl ^0.18.0, version solving failed.
    

    Attempts to resolve this by updating the intl version in the pubspec.yaml file led to further issues:

    Error: Version solving failed because every version of webfeed from git depends on intl ^0.18.0 and envoy depends on intl ^0.19.0.
    

Can anyone suggest on how to fix this?

Impact of the issue

None

If you found any similar or related issues, provide links to them here.

n/a

@keraliss keraliss added the bug Something isn't working label Aug 7, 2024
@InvertedX
Copy link
Collaborator

InvertedX commented Aug 7, 2024

Hi @keraliss,
It looks like the Flutter version you're using to build is 3.24.0. Currently, Envoy doesn't support this version, which is causing a conflict with the intl package.

Could you please use version 3.19 and try again? You can refer to our Docker file to find the correct package version required for the build: DockerFile.

@keraliss
Copy link
Author

keraliss commented Aug 7, 2024

Sure, thanks for the response, will try with 3.19 and revert back!

@keraliss
Copy link
Author

hey, update for envoy, i tried build from the docker file and run the container. The build was successful, it runs as well, but was unable to generate an apk despite my efforts. would highly appreciate if you can let me know how you guys generate the apks, so i can replicate that!

Thanks in advance!

@icota
Copy link
Collaborator

icota commented Aug 19, 2024

Hi @keraliss

We run just docker-build-android and the APK and AAB files end up in the release folder. I tried building with your colleague in #1206 previously but got no feedback. Is it okay to close that issue now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants