kolbasa/cordova-plugin-apkupdater

failed to parse package

Closed this issue · 6 comments

good night friend, please help me, I've been using your plugin for some time, I have many cases that after the end of the download I get "failed to parse package" and it doesn't install, if I try a few times (2,3) I can do the successful installation. sorry about my English

My first assumption would be: there is something wrong with the APK itself.
Maybe the signature was changed in the APK. Maybe corrupted.

Can you install the APK without the plugin?
If so, I need some details.

  • Plugin version
  • Android version
  • Is the APK zipped?

The easiest way to debug it is to connect the device to the PC and read the logcat.
Either via Android Studio or via the command: adb logcat.

Thank you very much for the brief feedback, If I install the apk manually (without using the plug) I always have success. I'm splitting the apk into 1 mb loss, total 18 loss with the manifest. Again I say that in a few attempts without any change in the code I get success using the plug, I'll leave a piece of my code below.

plugin version: cordova-plugin-apkupdater 1.2.3 "Apk Updater"

Android version:8.1.0

ionic v3
Angular CLI: 8.0.2

cordova.plugins.apkupdater.setObserver(
{
downloadProgress: function (nPercentage, nBytes, nBytesWritten, nChunks, nChunksWritten) {
this.downloadProgressAPK = nPercentage

      console.log('Download: ' + nPercentage + ' (' + nChunksWritten + '/' + nChunks + ')');

      this.downloadProgressAPK = nPercentage;

    this.downloadProgressAPK = "Progresso do Download" + " " + parseInt(this.downloadProgressAPK) + "%";


      document.getElementById('download').innerText = this.downloadProgressAPK ;

    },
    unzipProgress: function (nPercentage) {
  
        console.log('Unzipping: ' + nPercentage);
    },
    event: function (sEvent) {
     
        console.log(sEvent);
    },
    exception: function (sMessage, sStack) {
     
        console.error(sMessage, sStack);
    }
}

);

await cordova.plugins.apkupdater.check('https://www/manifest.json').then(async res => {

console.log(res)

this.newVersionDownload = res.version

if(this.appVersao==res.version){

let alert = this.alertCtrl.create({
  title: "O Teclado ja esta na ultima versão disponivel",
  cssClass:"alertClass" ,
  mode:'ios',

  });
  alert.present();

}else{

this.baixandoNewVersion=true

var erro=0
    do{
await cordova.plugins.apkupdater.download().then(async res => {
  this.baixandoNewVersion=false

  console.log("aplicativo baixando")
  await cordova.plugins.apkupdater.install().then(async res => {

    console.log(res)

  //
  }).catch(err =>{
    console.log("erro ao instalar")

    let alert2 = this.alertCtrl.create({
      title: 'falha no download, verifique se o teclado esta conectado com a internet e tente novamente',
      cssClass:"alertClass" ,
      mode:'ios',
      buttons: [
        {
          text: 'Tentar novamente',
          handler: () => {
            this.updateApp();
            alert2.dismiss()
            erro=1
          }
        }
      ]
      });

      alert2.present();


  })
  erro=0
}).catch(err =>{
  console.log(err)


      if(err=="Download failed"){
        erro++;

        if(erro == 60){
          erro=0

          let alert = this.alertCtrl.create({
            title: 'falha no download, verifique se o teclado esta conectado com a internet e tente novamente',
            cssClass:"alertClass" ,
            mode:'ios',
            buttons: [
              {
                text: 'Tentar novamente',
                handler: () => {
                  this.updateApp();
                  alert.dismiss()
                  erro=1
                }
              }
            ]
            });

            alert.present();


        }

      }

})

}while (erro >=1 && erro<60)

}

}).catch(err =>{

if(err=="Download failed"){

let alert1 = this.alertCtrl.create({
  title: "Falha ao consultar servidor, por favor verifique se o teclado esta com internet",
  cssClass:"alertClass" ,
  mode:'ios',

  });
  alert1.present();

}

console.log(err)
})

await cordova.plugins.apkupdater.reset();
})

I would recommend you to migrate to the new plugin version (> 2.0.0). This version is much better designed and less buggy.

Thank you very much for the feedback !!

I updated the plug it was show, very good to be able to put the entire apk on the server.

I'm going to test now I believe the error will be corrected, I have a question, is it possible to install the apk without user intervention?

If the device is rooted, then there is this option. This will install the update and also restart the app afterwards.
All without the app user's intervention.

await ApkUpdater.rootInstall();

There is a second way. If the app is registered as Device Admin, then this would work even without root.
However, I have not yet implemented a method for this. But that is planned soon.

thank you very much for the feedback but my device is not rooted