Running npx cap build android generates [error] jarsigner: unable to open jar file build\outputs\apk\release\app-release-unsigned.apk`
If I look in the build output, I have the APK, but it is called app-release.apk.
The signing is being conducted by the command therefore I cannot change the jarsigner command.
I thought this may be specific to my environment but I have created it in gitlab docker pipeline and get the same error.
Can I control the name of the output apk file via the cap build android command? I can’t find the docs for the commandline parameters for this?
TIA
Thanks for the link. Sadly it doesnt have a way to change the apk location or specify anything that could resolve the issue. Any ideas on the error?
What is the full command you are running?
npx cap build android from my command line on my PC or via a docker gitlab pipeline this is my whole pipeline:
image: registry.gitlab.com/fdroid/fdroidserver:buildserver-bullseye
# List of stages for jobs, and their order of execution
stages:
- build
variables:
# developer.android.com/studio#cmdline-tools
ANDROID_SDK_TOOLS: "11076708"
ANDROID_COMPILE_SDK: "34"
ANDROID_BUILD_TOOLS: "34.0.0"
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
install-and-build:
stage: build
script:
- cd ui
- apt-get update
- apt-get install -y ca-certificates gnupg
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
- NODE_MAJOR=23
- echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
- apt-get update
#node-install:
- apt-get install nodejs -y
#java-install:
- apt-get install -y -q openjdk-17-jre openjdk-17-jdk-headless
#android-install:
- apt-get install wget -y
- wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
- unzip -d sdk android-sdk.zip
- export ANDROID_HOME=$PWD/sdk
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/bin/
- set +o pipefail
- yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --licenses --sdk_root=sdk
- set -o pipefail
- echo y | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=sdk "cmdline-tools;latest" "build-tools;${ANDROID_BUILD_TOOLS}" "platforms;android-${ANDROID_COMPILE_SDK}" "platform-tools" >/dev/null
- chmod +x ./android/gradlew
#app-build:
- npm install
- npm run build
#android-build:
- npx cap sync android
- cp my-release-key.keystore android/app/my-release-key.keystore
- npx cap build android
artifacts:
paths:
- ui/dist/
- ui/android/app/build/outputs/apk/release/*.apk
So I had same problem, what helped me is to delete android directory, add it again with npx cap add android the run build of your app and npx cap sync - after run npx cap build android → get error that cant find android sdk path something like this → ***What went wrong:
Could not determine the dependencies of task ‘:app:lintVitalReportRelease’.
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting
the sdk.dir path in your project’s local properties file at ‘C:\Projects\tv-app\android\local.properties’.***
Solution just create this file local.properties with this inside sdk.dir=C:\Users\User\AppData\Local\Android\Sdk - User can be different depends what is your user name - after run npx cap build android