Flutter Azure Devops Firebase: error: unknown option '--app' - android

I am trying to setup a pipeline that adds the apk to the app distribution in firebase. I have the following yml:
# Flutter build
variables:
app_token: 1:403...
firebase_token: 1//dsads...
trigger:
- develop
jobs:
- job: Android
pool:
vmImage: 'windows-latest'
steps:
- task: FlutterInstall#0
inputs:
channel: 'stable'
version: 'latest'
- task: FlutterBuild#0
inputs:
target: apk
- task: CopyFiles#2
inputs:
contents: '**/*.apk'
targetFolder: '$(build.artifactStagingDirectory)'
- task: PublishBuildArtifacts#1
inputs:
artifactName: 'myartifactname'
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: CmdLine#2
inputs:
script: 'npm install -g firebase-tools'
workingDirectory: '$(Agent.ToolsDirectory)'
displayName: 'install firebase tools'
- task: Bash#3
displayName: "Upload to firebase app distribution"
inputs:
targetType: "inline"
script: |
npm i -g firebase-tools
firebase appdistribution: distribute android/app/build/outputs/apk/release/app-release.apk \
--app "$(app_token)" \
--release-notes "From Azure Devops" \
--groups "testgroup" \
--token "$(firebase_token)"
This is the log:
C:\npm\prefix\firebase -> C:\npm\prefix\node_modules\firebase-tools\lib\bin\firebase.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.3.2 (node_modules\firebase-tools\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ firebase-tools#9.19.0
updated 1 package in 11.855s
ls: cannot access 'D:a1a/build/app/outputs/flutter-apk': No such file or directory
error: unknown option '--app'
##[error]Bash exited with code '1'.
I don't find that what is wrong and how to fix it. Any help is appreciated.
Mostly code but not sure if you guys need additional informations. Thanks in advance.

Related

Azure Pipeline cmdLine error Bash exited with code '1'

I am going through the azure pipeline for my Android project. Issue is that local.properties file is in .gitignore so getting error local.properties not found for this i added its in secure file and now in YAML file i am downloading and installing taht secure file.
But I am stuck on the CmdLine step. line 18 error ##[error]Bash exited with code '1'.,
As for the pipeline yaml, I am using this template for android
# Android
# Build your Android project with Gradle.
# Add steps that test, sign, and distribute the APK, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/android
trigger:
- dev_pooja
pool:
vmImage: 'macos-latest'
steps:
- task: DownloadSecureFile#1
name: localProperties
displayName: 'Download Local Properties file'
inputs:
secureFile: 'local.properties'
- script: |
echo Installing $(localProperties.secureFilePath) to the trusted directory...
sudo chown root:root $(localProperties.secureFilePath)
sudo chmod a+r $(localProperties.secureFilePath)
sudo ln -s -f /etc/ssl/certs/ $(localproperties.secureFilePath)
- task: JavaToolInstaller#0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'
- task: Gradle#2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'assembleDebug'
- task: CopyFiles#2
inputs:
contents: "**/*.apk"
targetFolder: "$(build.artifactsStagingDirectory)"
- task: PublishBuildArtifacts#1
The error line : sudo ln -s -t /etc/ssl/certs/ $(localproperties.secureFilePath).
Try removing -t flag. In addition, you may need -f flag: If the target file already exists, then unlink it so that the link may occur.
Good luck!

Ionic Capacitor Android YAML build fails due to zipalign error

I have an Ionic Capacitor Android app that I need to set up an Azure DevOps yaml pipeline for.
Here's my yaml:
- task: JavaToolInstaller#0
inputs:
versionSpec: "11"
jdkArchitectureOption: "x64"
jdkSourceOption: "PreInstalled"
displayName: "Install JDK v11"
- task: NodeTool#0
inputs:
versionSpec: "16.x"
displayName: "Install Node.js v16.x"
- task: Npm#1
inputs:
workingDir: "$(projectDirectory)"
command: install
displayName: "NPM Install"
- task: Npm#1
inputs:
command: "custom"
workingDir: "$(projectDirectory)"
customCommand: "install -g #ionic/cli"
displayName: "NPM Install Ionic CLI"
- powershell: |
ionic cap build android --no-open
npx cap sync android
workingDirectory: $(projectDirectory)
displayName: "Android: Ionic Cap Build and Sync"
- task: Gradle#3
inputs:
workingDirectory: $(projectDirectory)/android
gradleWrapperFile: "$(projectDirectory)/android/gradlew"
publishJUnitResults: false
tasks: assembleRelease
displayName: "Android: Build APK"
- task: AndroidSigning#3
displayName: "Android: Sign .APK file(s)"
inputs:
apkFiles: "$(projectDirectory)/android/app/build/outputs/apk/$(buildConfiguration)/*.apk"
apksign: true
apksignerKeystoreFile: "$(ts-secure-file-name)"
apksignerKeystorePassword: "$(ts-keystore-password)"
apksignerKeystoreAlias: "$(ts-keystore-alias)"
apksignerKeyPassword: "$(ts-keystore-password)"
zipalign: true # zipalign is no longer needed ? ref: https://stackoverflow.com/a/64973262/1508398
With this, I get the error at Android Signing step saying
Unable to open
'D:\a\1\s\Source\node_modules\webdriver-js-extender\built\built\built\built\built\built\built\built\built\built\built\built\built\built\built\built\spec\comm
##[error]Error: The process 'C:\Android\android-sdk\build-tools\33.0.0\zipalign.exe' failed with
exit code 1
When I set the zipAlign:false, then the signing fails saying:
Exception in thread "main" com.android.apksig.apk.ApkFormatException:
Malformed APK: not a ZIP archive
I am really new to this. Any idea on what I am missing out here?

Azure DevOps iOS and Android React Native Build Failing on Pod Install and Gradle Build Steps

I am trying to create CI/CD pipeline, for iOS and android, in Azure Devops for a React-Native app.
With the android pipeline, whether I choose to create a yaml or use the classic editor and use pre-configured android tasks, the pipeline always fails on the build task (bundleRelease). The error I receive is:
FAILURE: Build failed with an exception.
Where:
Settings file '/home/vsts/work/1/s/app-rn/android/settings.gradle' line: 12
What went wrong:
A problem occurred evaluating settings 'iEquos'.
Could not read script '/home/vsts/work/1/s/app-rn/node_modules/#react-native-community/cli-platform-android/native_modules.gradle' as it does not exist.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 12s
Error: The process '/home/vsts/work/1/s/app-rn/android/gradlew' failed with exit code 1
at ExecState._setResult (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:944:25)
at ExecState.CheckComplete (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:927:18)
at ChildProcess. (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:840:19)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
##[error]Error: The process '/home/vsts/work/1/s/app-rn/android/gradlew' failed with exit code 1
Finishing: Gradle
This is line being referred to in android/settings.gradle:
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings, "../")
The node modules folder is in the 'app-rn' directory, at the same level as the "android" folder, so only using one "../" is correct?
I can build the android solution locally through a termianl or using Android studio so I am completely clueless to why this is occurring in DevOps.
A similar issue is occurring with my pipeline for iOS. The issue is occurring when istalling Cocoa Pods:
DevOps Install Cocoa Pods Error
Here is an image of my PodFile, located in the 'iOS' folder. The 'iOS' folder is located at the same level as 'node-modules', both inside a folder 'app-rn':
Podfile
Here is the yaml for android:
# Android
# Build your Android project with Gradle.
# Add steps that test, sign, and distribute the APK, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/android
variables:
- group: DriverApp
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
name: $(date:yyyy).$(Month)$(rev:.r)
steps:
- script: yarn install
- task: Gradle#2
inputs:
gradleWrapperFile: 'app-rn/android/gradlew'
workingDirectory: 'app-rn/android/'
options: '-PversionName=$(Build.BuildNumber) -PversionCode=$(Build.BuildId)'
tasks: 'bundleRelease'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
gradleOptions: '-Xmx3072m'
sonarQubeRunAnalysis: false
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.aab'
apksignerKeystoreFile: 'keystore.jks'
apksignerKeystorePassword: '$(AndroidKeyStorePassword)'
apksignerKeystoreAlias: '$(AndroidKeyAlias)'
apksignerKeyPassword: '$(AndroidKeyAliasPassword)'
zipalign: false
- task: PublishBuildArtifacts#1
inputs:
# PathtoPublish: 'android/app/build/outputs/apk/release'
PathtoPublish: 'android/app/build/outputs/'
ArtifactName: 'drop'
publishLocation: 'Container'
The yaml for iOS:
# trigger:
# branches:
# include:
# - master
variables:
- group: DriverApp
pool:
vmImage: 'macos-latest'
steps:
- checkout: self
persistCredentials: true
clean: true
- task: NodeTool#0
displayName: 'Install Node'
inputs:
versionSpec: '12.19.0' # you can use your desired version here
# workingDirectory: 'app-rn/'
- script: yarn install
displayName: Install Dependencies
- task: InstallAppleCertificate#2
displayName: Install Apple Certificate
inputs:
certSecureFile: 'AppleDistributionCertificate.p12'
certPwd: '$(AppleCertificatePassword)'
keychain: 'temp'
deleteCert: true
- task: InstallAppleProvisioningProfile#1
displayName: 'Install Apple Provisioning Profile'
inputs:
provisioningProfileLocation: 'secureFiles'
provProfileSecureFile: 'iEquos_App_Store.mobileprovision'
removeProfile: true
- task: CocoaPods#0
displayName: 'Install CocoaPods'
inputs:
workingDirectory: 'app-rn/ios'
- task: Xcode#5
displayName: 'Build IPA'
inputs:
actions: 'build'
configuration: 'Release'
sdk: 'iphoneos'
xcWorkspacePath: 'app-rn/ios/iEquos.xcworkspace'
scheme: 'iEquos'
packageApp: true
exportPath: 'output'
signingOption: 'manual'
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
- task: CopyFiles#2
displayName: 'Copy IPA'
inputs:
contents: '**/*.ipa'
targetFolder: '$(build.artifactStagingDirectory)'
overWrite: true
flattenFolders: true
- task: PublishBuildArtifacts#1
displayName: 'Publish IPA to artifacts'
inputs:
PathtoPublish: '$(build.artifactStagingDirectory)'
ArtifactName: 'ios'
publishLocation: 'Container'
I have searched stackoverflow for similar issues, but only seem to find people running into these issues locally, nto within DevOps. As I mentioned before, I can build the android and iOS app locally.
I am fairly new to posting on stack overflow so please let me know if I should provide anymore information.
Any help would be greatly appreciated.
Have you tried this in azure-pipelines.yml file:
- script: /usr/local/bin/pod deintegrate
workingDirectory: 'app-rn/ios'
displayName: 'pod deintegrate'
- script: /usr/local/bin/pod install
workingDirectory: 'app-rn/ios'
displayName: 'pod install'
insted of:
- task: CocoaPods#0
displayName: 'Install CocoaPods'
inputs:
workingDirectory: 'app-rn/ios'

Azure Pipeline run tasks based on the designated android flavor

I have a pipeline that ones running perfectly when my application wasn't flavored.
it was building, signing and releasing the application to the firebase distribution.
Now I have the application flavored and I want on each push to development to release the app whether on com.example_flavor1 or com.example_flavor2
the gradle task and the firebase app id should change according to the flavor but i'm not knowing how to do so, can you help please
Here's my pipeline
trigger:
- development
variables:
- group: 'Variables'
stages:
- stage: Build
displayName: Build & Archive
jobs:
- job: build
displayName: build
pool:
vmImage: $(vmImage)
steps:
- task: Gradle#2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'assembleRelease --stacktrace'
- task: DownloadSecureFile#1
displayName: Retrieving the Keystore
inputs:
secureFile: 'keystore.keystore'
- task: AndroidSigning#3
displayName: Signing the Release 2
inputs:
apkFiles: '**/*.apk'
apksign: true
apksignerKeystoreFile: 'keystore.keystore'
apksignerKeystorePassword: '$(KeyStorePassword)'
apksignerKeystoreAlias: '$(KeyAlias)'
apksignerKeyPassword: '$(KeyPassword)'
apksignerArguments: --out $(Build.SourcesDirectory)/app/build/outputs/apk/release/app-$(MajorVersion).$(MinorVersion).$(Build.BuildID)-release.apk
zipalign: false
- task: CopyFiles#2
displayName: Archive APKs
inputs:
contents: '**/*.apk'
targetFolder: '$(build.artifactStagingDirectory)/apk'
- task: CopyFiles#2
displayName: Archive AABs
inputs:
contents: '**/*.aab'
targetFolder: '$(build.artifactStagingDirectory)/aab'
- task: PublishBuildArtifacts#1
displayName: Publish build artifacts
inputs:
pathToPublish: '$(build.artifactStagingDirectory)'
artifactName: '$(MajorVersion).$(MinorVersion).$(Build.BuildID)'
- stage: Publish
displayName: Publish
condition: succeeded()
jobs:
- deployment:
displayName: Firebase Tools install and deploy
pool:
vmImage: $(vmImage)
environment: Dev
strategy:
runOnce:
deploy:
steps:
- task: NodeTool#0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
artifactName: '$(MajorVersion).$(MinorVersion).$(Build.BuildID)'
downloadPath: '$(System.ArtifactsDirectory)'
- script: |
cd $(Pipeline.Workspace)
npm install -g firebase-tools
firebase appdistribution:distribute $(System.ArtifactsDirectory)/$(MajorVersion).$(MinorVersion).$(Build.BuildID)/apk/app/build/outputs/apk/release/app-$(MajorVersion).$(MinorVersion).$(Build.BuildID)-release.apk --project $(firebase-project-id) --app $(firebase-android-app-id) --token $(firebase-token) --testers "$(firebase-testers-emails)" --groups "$(firebase-testers-groups)" --release-notes "$(release-notes)" --debug
displayName: 'npm install and distribute'
You could implement parallel jobs in Azure Devops to support an arbitrary number of Gradle flavors an Android app. And use Templates to define reusable content, logic, and parameters. For example:
jobs:
- job: A
variables:
- group: "A"
steps:
- template: build.yml
- job: B
variables:
- group: "B"
steps:
- template: build.yml
Here is a simple example you may refer to:
https://github.com/seanKenkeremath/AzureDevopsAndroidFlavorsExample

Azure DevOps distribute android app via appcenter not distributing

I have a react native app building on Azure Devops ok,
now to create the distribution, it shows a grey arrow on the "jobs", and I cannot find the app distributed,
What is Result: False ?
here the yaml
trigger:
- master
pool:
vmImage: 'macOS-10.14'
variables:
- group: AndroidKeystore
steps:
- task: NodeTool#0
displayName: 'Install Node'
inputs:
versionSpec: '12.16.1'
- script: npm install
displayName: 'Install node dependencies'
- script: |
npm i jetifier
npx jetify
displayName: 'npx'
- script: |
rm -r android/app/src/main/res/drawable-*
rm -r android/app/src/main/res/raw
displayName: 'delete before'
- task: Gradle#2
inputs:
workingDirectory: 'android'
gradleWrapperFile: 'android/gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'assembleRelease'
- task: AndroidSigning#3
inputs:
apkFiles: '**/*.apk'
apksign: true
apksignerKeystoreFile: 'my-release-key.keystore'
apksignerKeystorePassword: '$(jarsignerKeystorePassword)'
apksignerKeystoreAlias: 'my-key-alias'
apksignerKeyPassword: '$(jarsignerKeyPassword)'
- script: mv android/app/build/outputs/apk/release/app-release.apk ReactNativePipeline$(Build.BuildNumber).apk
displayName: 'Rename apk'
- task: PublishBuildArtifacts#1
inputs:
pathtoPublish: ReactNativePipeline$(Build.BuildNumber).apk
artifactName: drop
publishLocation: 'container'
- task: AppCenterDistribute#3
displayName: "Create a release on App Center"
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
serverEndpoint: 'VSAC'
appSlug: 'Wisr/WisrRN-Android2'
appFile: 'ReactNativePipeline$(Build.BuildNumber).apk'
releaseNotesOption: 'input'
releaseNotesInput: |
$(Build.SourceVersionMessage)
latest source: '$(Build.SourceVersion)'
An automated release from Azure DevOps
destinationType: 'groups'
distributionGroupId: 'testBench'
So how to make the build available on the specific group "testBench"
What is Result: False ?
This is the result of condition. From the task log, the Build.SourceBranch is refs/heads/androidPipe.
refs/heads/androidPipe eq refs/heads/master Result: false
In your Yaml sample, the condition settings:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
This means that when the Build.SourceBranch is master, it will run the AppCenterDistribute task. Or it will not run the task(Skip the task).
Here are two methods to solve this issue:
1.You could change the Condition:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/androidPipe'))
2.You could use the master branch to run the pipeline. Then the task will execute.
By the way, if you don't need this condition, you can also delete it. In this case, no matter what branch it is, this task will run.
For more detailed information, you could refer to this doc about Condition.

Categories

Resources