This is a very wierd issue. When I build a signed apk locally either through vscode or android studio, the apk works perfect.
These are my commands that I use to build. Like I said locally this works fine
ionic build --prod
npx cap sync
npx cap copy
cd android
./gradle assembleRelease
However when I upload to Gitlab I use the same sequence and the apk is built to the outputs/apk/release folder fine but when installing I get just a white screen.
Here is the gitlab that I am using
build_android:
stage: build
script:
- npm install -g @ionic/cli --legacy-peer-deps
- npm install @capacitor/core @capacitor/cli --legacy-peer-deps
- ionic build --prod
- npx cap sync android
- npx cap copy
artifacts:
paths:
- node_modules
cache:
key:
files:
- package-lock.json
- package.json
paths:
- node_modules/
- android
policy: pull
sign_android:
stage: sign
image: eclipse-temurin:17-jdk-jammy
needs: [build_android]
# Packages installation before running script
script:
- ls
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget unzip
- export ANDROID_HOME="${PWD}/android-sdk-root"
- install -d $ANDROID_HOME
# Here we are installing androidSDK tools from official source,
# (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well)
# after that unzipping those tools and
# then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build
- wget --no-verbose --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
- unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/cmdline-tools.zip"
- mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin
- wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/${ANDROID_GRADLE_VERSION}-bin.zip
- unzip -q gradle.zip
# Nothing fancy here, just checking sdkManager version
- sdkmanager --version
# use yes to accept all licenses
- yes | sdkmanager --licenses > /dev/null || true
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
- sdkmanager "platform-tools"
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
- cd android
- ./gradlew assembleRelease
artifacts:
paths:
- android/app/build/outputs/apk/release/app-release.apk