我的Flutter发布apk更新时有冲突的包

问题描述 投票:0回答:1

这是专门针对 Android 的。我有一个 flutter 应用程序,它通过 DevOps 管道构建 apk,然后将其发布到 App Center 供内部使用。当我通过应用程序中心下载新的应用程序并选择更新时,我在轻松更新应用程序时遇到了问题。每次我收到消息“应用程序未安装,因为包与现有包冲突”。

我知道只需卸载旧应用程序然后安装新应用程序的解决方案,但是我没有其他方法可以让我的更新处于工作状态吗?我的软件包是否有任何可能会发生冲突的地方,我可以通过匹配这些地方来轻松完成更新过程?

我尝试在我的项目和管道中的任何地方查找任何标识符或进程,这些标识符或进程可能会使它看起来像是在论坛的帮助下具有相同名称的不同包,例如:

  • Android 命名空间
  • 我在管道中签署应用程序的密钥库

但是两个版本之间的命名空间保持不变,并且我的密钥库绝对没有改变,因为它存储在 DevOps 上的安全文件中并且根本没有被触及。

然而,有些事情确实发生了变化,可以被认为是重大的,我不知道它是否会认为它完全是一个不同的包,例如:

  • 将我的 flutter、gradle 和所有其他包更新到最新版本
  • 添加口味
  • 大部分图像资源已被替换
  • 由于口味的原因,我的 apk 名称从 app-release.apk 更改为 app-prod-release.apk
  • 并使用新任务和使用风格和配置文件构建 apk 的新方法来更新管道,如下所示:

旧管道:

trigger:
  branches:
    include:
      - dev
      - main
      - release/*

stages:
- stage: AndroidStage
  pool:
    vmImage: 'ubuntu-latest'
  dependsOn: []
  displayName: Android
  jobs:

  - job: AndroidJob
    displayName: Android
    steps: 

    - task: FlutterInstall@0
      displayName: "Install Flutter SDK"
      inputs:
        mode: 'auto'
        channel: 'stable'
        version: 'latest'

    - task: FlutterCommand@0
      displayName: "Run Flutter diagnostics"
      inputs:
        projectDirectory: '.'
        arguments: 'doctor -v'

    - task: FlutterBuild@0
      displayName: "Build application"
      inputs:
        target: 'apk'
        projectDirectory: '$(Build.SourcesDirectory)'

    - task: AndroidSigning@3
      displayName: 'Signing and aligning APK file(s) **/*.apk'
      inputs:
        apkFiles: '**/*.apk'
        apksign: true
        apksignerKeystoreFile: pinnies-v2-release.keystore
        apksignerKeystorePassword: $(keystorePass)
        apksignerKeystoreAlias: $(keystoreAlias)
        apksignerKeyPassword: $(keystorePass)

    - task: CopyFiles@2
      inputs:
        contents: '**/*.apk'
        targetFolder: '$(build.artifactStagingDirectory)'
        OverWrite: true

    - task: PublishBuildArtifacts@1
      condition: ne(variables['Build.Reason'], 'PullRequest')
      inputs:
        artifactName: 'drop'
    
    - script: |
        version=$(grep "version:" pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
        echo "##vso[task.setvariable variable=AppVersion]$version"
      displayName: 'Extract App Version'

    - script: |   
        if [ "$(Build.SourceBranch)" == "refs/heads/main" ]; then
          echo '$url = "$(teamsUrl)"' > $(Build.ArtifactStagingDirectory)/send_teams.ps1
        else
          echo '$url = "$(teamsGradUrl)"' > $(Build.ArtifactStagingDirectory)/send_teams.ps1
        fi
        echo '$jsonPayload = @{' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '    "version" = "$(AppVersion)"' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        if [ "$(Build.SourceBranch)" == "refs/heads/main" ]; then
          echo '    "url" = "https://install.appcenter.ms/orgs/agilebridge/apps/pinnies-android/distribution_groups/public"' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        else
          echo '    "url" = "https://install.appcenter.ms/orgs/AgileBridge/apps/Pinnies-Test-Android/releases/latest"' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        fi
        echo '}' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$jsonBody = $jsonPayload | ConvertTo-Json' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$headers = @{ "Content-Type" = "application/json" }' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$response = Invoke-RestMethod -Uri $url -Method Post -Body $jsonBody -Headers $headers' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$response' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
      displayName: 'Generate PowerShell Script'
    
    - publish: $(Build.ArtifactStagingDirectory)/send_teams.ps1
      artifact: SendTeams

新管道:

trigger:
  branches:
    include:
      - dev
      - main
      - release/*

stages:
- stage: AndroidStage
  pool:
    vmImage: 'ubuntu-latest'
  dependsOn: []
  displayName: Android
  jobs:

  - job: AndroidJob
    displayName: Android
    steps:
    - bash: 'wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz '
      displayName: 'Bash Script'

    - task: JavaToolInstaller@0
      displayName: 'Use Java 21'
      inputs:
        versionSpec: 21
        jdkArchitectureOption: x64
        jdkSourceOption: LocalDirectory
        jdkFile: '$(build.sourcesdirectory)/jdk-21_linux-x64_bin.tar.gz'
        jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk21'

    - task: FlutterInstall@0
      displayName: "Install Flutter SDK"
      inputs:
        mode: 'auto'
        channel: 'stable'
        version: 'latest'

    - task: FlutterCommand@0
      displayName: "Run Flutter diagnostics"
      inputs:
        projectDirectory: '.'
        arguments: 'doctor -v'

    - task: FlutterCommand@0
      displayName: "Clean application"
      inputs:
        projectDirectory: '.'
        flutterDirectory: '$(Build.SourcesDirectory)'
        arguments: 'clean'

    - script: |
        if [[ "$(Build.SourceBranch)" == "refs/heads/dev" ]]; then
          flavor="dev"
        elif [[ "$(Build.SourceBranch)" == "refs/heads/main" ]]; then
          flavor="prod"
        else
          flavor="uat"
        fi
        echo "Building with flavor: $flavor"
        flutter build apk --flavor $flavor --dart-define-from-file=config/app_config_$flavor.json
      displayName: "Build application with flavor"

    - task: AndroidSigning@3
      displayName: 'Signing and aligning APK file(s) **/*.apk'
      inputs:
        apkFiles: '**/*.apk'
        apksign: true
        apksignerKeystoreFile: pinnies-v2-release.keystore
        apksignerKeystorePassword: $(keystorePass)
        apksignerKeystoreAlias: $(keystoreAlias)
        apksignerKeyPassword: $(keystorePass)

    - task: CopyFiles@2
      inputs:
        contents: '**/*.apk'
        targetFolder: '$(build.artifactStagingDirectory)'
        OverWrite: true

    - task: PublishBuildArtifacts@1
      condition: ne(variables['Build.Reason'], 'PullRequest')
      inputs:
        artifactName: 'drop'
    
    - script: |
        version=$(grep "version:" pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
        echo "##vso[task.setvariable variable=AppVersion]$version"
      displayName: 'Extract App Version'

    - script: |   
        if [ "$(Build.SourceBranch)" == "refs/heads/main" ]; then
          echo '$url = "$(teamsUrl)"' > $(Build.ArtifactStagingDirectory)/send_teams.ps1
        else
          echo '$url = "$(teamsGradUrl)"' > $(Build.ArtifactStagingDirectory)/send_teams.ps1
        fi
        echo '$jsonPayload = @{' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '    "version" = "$(AppVersion)"' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        if [ "$(Build.SourceBranch)" == "refs/heads/main" ]; then
          echo '    "url" = "https://install.appcenter.ms/orgs/agilebridge/apps/pinnies-android/distribution_groups/public"' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        else
          echo '    "url" = "https://install.appcenter.ms/orgs/AgileBridge/apps/Pinnies-Test-Android/releases/latest"' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        fi
        echo '}' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$jsonBody = $jsonPayload | ConvertTo-Json' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$headers = @{ "Content-Type" = "application/json" }' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$response = Invoke-RestMethod -Uri $url -Method Post -Body $jsonBody -Headers $headers' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
        echo '$response' >> $(Build.ArtifactStagingDirectory)/send_teams.ps1
      displayName: 'Generate PowerShell Script'
    
    - publish: $(Build.ArtifactStagingDirectory)/send_teams.ps1
      artifact: SendTeams

我真的很不知所措。我认为应用程序中心不会导致此问题,因为这也没有改变。我对移动开发还比较陌生,因此任何可以为我指明正确方向的建议将不胜感激

android flutter mobile devops azure-pipelines-release-pipeline
1个回答
0
投票

您每次都会升级应用程序的版本号吗?具体来说,我指的是 Apps build.gradle 中的 versionCode。

© www.soinside.com 2019 - 2024. All rights reserved.