i´m facing a problem at the moment with cordova CLI with a .bat script file to build, sign and create a working APK to install in my android device. My script do every procedure that is needed to do this.
The problem that i´m facing is when the script get in the build part (cordova build –release android), it builds sucessfully but the .bat script ends unexpectedly.
The current script
“””””””
@echo off
setlocal enabledelayedexpansion
REM Define log file
echo Build started at %date% %time%
REM Change to the Cordova project directory
echo “Changing to the Cordova project directory”
cd appDir || (
echo “Error changing to the Cordova project directory, build process canceled”
)
set “NEW_DIRECTORY=!CD!”
echo “New directory: !NEW_DIRECTORY!”
REM Build the release version
echo “————————————————–Building the release started————————————————–”
npx cordova build –release android || (
echo “Error building the release version”
)
echo “————————————————–Building the release finished————————————————-“
REM Navigate to the AAB output directory
echo “Changing to the AAB output directory”
cd appDirplatformsandroidappbuildoutputsbundlerelease || (
echo “Error changing to the AAB output directory”
)
set “BUNDLE_DIRECTORY=!CD!”
echo “New directory: !BUNDLE_DIRECTORY!”
REM Use bundletool to sign, align, and generate the final AAB
echo “Calling bundletool to assemble the APKs”
bundletool build-apks –bundle=app-release.aab –output=app-release-prod.apks –ks=…………..mykeystoredummie.keystore –ks-pass=pass:***** –ks-key-alias=***** –key-pass=pass:******
echo “APKs generated using bundletool”
echo “Generated files:”
dir /b /a-d “!CD!”
REM Extract the APKs from the apks file
echo “Calling bundletool to extract the APKs from extract-apks”
bundletool extract-apks –apks=app-release-prod.apks –output-dir=extracted_apks
echo “APKs extracted from the APKs file”
echo “Generated files:”
dir /b /a-d “!CD!”
REM Sign and align each extracted APK
echo “For each item in extract-apks will sign and align”
for %%F in (extracted_apks*.apk) do (
echo “Processing %%F”
apksigner sign –ks=…………..mykeystoredummie.keystore –ks-pass=pass:***** –key-pass=pass:***** –in=”%%F” –out=”signed_%%~nxF”
echo “APK %%F signed”
%USERPROFILE%AppDataLocalAndroidSdkbuild-tools33.0.2zipalign -v 4 “signed_%%~nxF” “aligned_%%~nxF”
echo “APK %%F aligned”
)
REM Copy the aligned APKs to a desired location
echo “Copying the signed APKs to a destination location”
copy aligned_* …………..
echo “Aligned APKs copied to the destination”
REM Return to the original directory
cd …………..
echo “Returned to the original directory”
echo “Build completed successfully”
echo Build completed successfully at %date% %time%
endlocal
exit /b 0
“””””””””
Already checked if the next line after the cordova build its working and it is pretty well. Anyone have seen something similar ?