1

I am trying to create an apk from azure devops pipelines, and the apk gets successfully generated. But when I try to install that apk generated in to the emulator, i am getting this error

Failed to commit install session 762751184 with command cmd package install-commit 762751184. Error: INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2

When I am trying to install it in the device I am getting,

App not installed as package appears to be invalid

This is the pipeline code,

steps:
  - task: android-manifest-version@1
    inputs:
      sourcePath: 'android/app/src/main/AndroidManifest.xml'
      versionCodeOption: 'buildid'
      versionCode: '$(Build.BuildId)'
      versionName: 
      printFile: true
  - task: Hey24sheep.flutter.flutter-build.FlutterBuild@0
    displayName: Build ${{ parameters.appSuffix }} App Bundle
    inputs:
      target: 'apk'
      projectDirectory: '$(Build.SourcesDirectory)'
      buildFlavour: '${{ parameters.appSuffix }}'
      entryPoint: ${{ parameters.flavorEntryPoint }}
  - task: DownloadSecureFile@1
    name: keystore
    displayName: Download keystore securely
    inputs:
      secureFile: ${{ parameters.keyStoreFile }}
  - task: AndroidSigning@3
    displayName: 'Signing and aligning APK file(s) **/*.apk'
    inputs:
      apkFiles: '**/*.apk'
      zipalign: true
      apksign: true
      apksignerKeystoreFile: ${{ parameters.keyStoreFile }}
      apksignerKeystorePassword: ${{ parameters.keyStorePassword }}
      apksignerKeystoreAlias: ${{ parameters.keyAlias }}
      apksignerKeyPassword: ${{ parameters.keyPassword }}
  - task: CopyFiles@2
    displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
    inputs:
      SourceFolder: '$(system.defaultworkingdirectory)'
      Contents: '**/*.apk'
      TargetFolder: '$(build.artifactstagingdirectory)'
      FlattenFolders: true
    condition: succeededOrFailed()
  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: drop'
    inputs:
      PathtoPublish: '$(build.artifactstagingdirectory)'

But when i add

android:extractNativeLibs="true"

to my android manifest then the application gets installed without any issue(in both emulator and device). But I want to keep android:extractNativeLibs=false so it would be really preferable if I could change from the pipeline code and make an executable apk. Any suggestions to make this work will be greatly appreciated.

SVG
  • 809
  • 6
  • 21

1 Answers1

1

To Anyone who is facing this issue,

Either you can set the minsdkversion in the app gradle file to less than or equal to 21 (since extractNativeLibs is true by default for those sdk versions: refer https://developer.android.com/guide/topics/manifest/application-element), or else you can keep the minsdkeversion as it is and explicitly define extractNativeLibs to true in the android manifest in the application tag. Hence this answer is only focused on the pipeline build as the question has posted, there might be other ways you could achieve this if you want to build it locally. (Such as answers posted in this thread Targeting SDK Android Q results in Failed to finalize session : INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2)

SVG
  • 809
  • 6
  • 21