Bonjour,
J'utilise dans mon application android une fonction donnée par windev dans une LST il me semble.
Qui permet de télécharger une apk depuis une url puis de faire l'installation de cette dernière.
Cela permet de vérifier que l'application est bien à la dernière version et de la mettre à jour dans le cas contraire.
J'ai le lancement du téléchargement et de la notification comme quoi l'application est en cour de téléchargement
puis j'ai l'erreur suivante :
Échec de l'instalation 4, INSTALL_PARSE_
FAILED_UNEXPECTED_EXCEPTION: Failed
to parse /data/app/vmdl215448992.tmp/
package: AndroidManifest.xml
Entre la version d'avant et la nouvelle version, j'ai ajouté un distinct sur un select. donc je pense pas avoir déclencher une modification dans le manifeste.
Quelqu'un pourrait m'aiguiller plus sur cette erreur Android.
voici la fonction java qui doit lancer la mise à jour:
_AutoUpdateFaireInstall_Android_Package(sFichierAPK)
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageInstaller;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.OutputStream;
import android.content.BroadcastReceiver;
import android.content.IntentFilter;
public static void _AutoUpdateFaireInstall_Android_Package( String apkLocation )
{
PackageInstaller.Session session = null;
try
{
PackageInstaller packageInstaller = getContexteApplication().getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
int sessionId = packageInstaller.createSession(params);
session = packageInstaller.openSession(sessionId);
OutputStream packageInSession = session.openWrite("package", 0, -1);
FileInputStream is = new FileInputStream(apkLocation);
byte[] buffer = new byte[16384];
int n;
while ((n = is.read(buffer)) >= 0) {
packageInSession.write(buffer, 0, n);
}
is.close();
packageInSession.close();
Context context = getActiviteEnCours();
Intent intent = new Intent("com.pcsoft.wmautoupdate.SESSION_API_PACKAGE_INSTALLED");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("com.pcsoft.wmautoupdate.SESSION_API_PACKAGE_INSTALLED");
context.registerReceiver(mBroadcastReceiver, intentFilter);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getContexteApplication(), 0, intent, 0);
IntentSender statusReceiver = pendingIntent.getIntentSender();
session.commit(statusReceiver);
session.close();
} catch (IOException e) {
throw new RuntimeException("Échec du déclenchement de l'installation de l'application.", e);
} catch (RuntimeException e) {
if (session != null) {
session.abandon();
}
throw e;
}
}
private final static BroadcastReceiver mBroadcastReceiver = new WMUpdateReceiver() ;
public static class WMUpdateReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
if ("com.pcsoft.wmautoupdate.SESSION_API_PACKAGE_INSTALLED".equals(intent.getAction())) {
int status = extras.getInt(PackageInstaller.EXTRA_STATUS);
String message = extras.getString(PackageInstaller.EXTRA_STATUS_MESSAGE);
switch (status) {
case PackageInstaller.STATUS_PENDING_USER_ACTION:
// This test app isn't privileged, so the user has to confirm the install.
Intent confirmIntent = (Intent) extras.get(Intent.EXTRA_INTENT);
context.startActivity(confirmIntent);
break;
case PackageInstaller.STATUS_SUCCESS:
Toast.makeText(context, "Installation terminée avec succès.", Toast.LENGTH_SHORT).show();
break;
case PackageInstaller.STATUS_FAILURE:
case PackageInstaller.STATUS_FAILURE_ABORTED:
case PackageInstaller.STATUS_FAILURE_BLOCKED:
case PackageInstaller.STATUS_FAILURE_CONFLICT:
case PackageInstaller.STATUS_FAILURE_INCOMPATIBLE:
case PackageInstaller.STATUS_FAILURE_INVALID:
case PackageInstaller.STATUS_FAILURE_STORAGE:
Toast.makeText(context, "Échec de l'installation " + status + ", " + message,
Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(context, "L'installeur Android a renvoyé un code d'état inconnu : " + status,
Toast.LENGTH_SHORT).show();
}
}
}
}
Procedure _AutoUpdateLanceMiseAJour()
SI gstInfoVersion.url_install_android_Chemin = "" ALORS
RETOUR
FIN
SI gstInfoVersion.url_install_android_Nom = "" ALORS
RETOUR
FIN
<Compile SI TypeConfiguration=Android>
sFichierInstall est une chaîne = SysRepStockageExterne(1, ssePublicTéléchargement) + [fSep] + "autoupdate.apk"
MOnHTTP est une chaîne = gstInfoVersion.url_install_android_Chemin+gsVersion+"/"+gstInfoVersion.url_install_android_Nom
SI fFichierExiste(sFichierInstall) ALORS
fSupprime(sFichierInstall)
FIN
HTTPDestination(sFichierInstall)
HTTPJauge("_AutoUpdateJauge")
gNotifUpdate.Titre = "Mise à jour en cours"
gNotifUpdate.Message = ""
NotifAjoute(gNotifUpdate)
SI httpRequête(MOnHTTP) ALORS
NotifSupprime(gNotifUpdate)
AutoUpdateFaireInstall_Android_ThreadPrincipal(sFichierInstall)
SINON
gNotifUpdate.Titre = "Échec de la mise à jour"
gNotifUpdate.Message = "Le téléchargement de la mise à jour a échoué."
NotifModifie(gNotifUpdate)
FIN
<FIN>
CAS ERREUR:
gNotifUpdate.Titre = "Échec de la mise à jour"
gNotifUpdate.Message = "Le téléchargement de la mise à jour a échoué."
NotifModifie(gNotifUpdate)
CAS EXCEPTION:
gNotifUpdate.Titre = "Échec de la mise à jour"
gNotifUpdate.Message = "Le téléchargement de la mise à jour a échoué."
NotifModifie(gNotifUpdate)
Procedure AutoUpdateFaireInstall_Android_ThreadPrincipal(sFichierAPK est une chaîne<utile>)
<Compile SI TypeConfiguration=Android>
_AutoUpdateFaireInstall_Android_Package(sFichierAPK)
<FIN>