Форум для тех, кто программирует под Android
Anonymous
Android PackageInstaller install_failed_internal_error: сеанс.
Сообщение
Anonymous » 09 июн 2025, 14:53
Я сталкиваюсь с проблемой, пытаясь установить APK с установщиком пакета. Установка не сбои с очень неясным сообщением о состоянии "install_failed_internal_error: Session Redquised". < /P>
Вот код, который устанавливает пакет: < /p>
Код: Выделить всё
public static void installPackage(Context context, String packageName, String apkPath)
{
Logger.debug("Installing package " + apkPath);
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL);
params.setAppPackageName(packageName);
try {
Logger.debug("Creating session");
int sessionId = packageInstaller.createSession(params);
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
Logger.debug("Copying buffer");
OutputStream out = session.openWrite(packageName, 0, -1);
FileInputStream fileInputStream = new FileInputStream(new File(apkPath));
byte[] buffer = new byte[1024];
int len = fileInputStream.read(buffer);
while(len != -1)
{
out.write(buffer,0, len);
len = fileInputStream.read(buffer);
}
session.fsync(out);
fileInputStream.close();
out.close();
Logger.debug("Buffer copied, sending intent");
Intent intent = new Intent(INSTALL_COMPLETE_ACTION);
IntentSender intentSender = PendingIntent.getBroadcast(context, sessionId,
intent, 0) .getIntentSender();
session.commit(intentSender);
session.close();
}
catch(IOException e)
{
Logger.error("IOException while installing package");
Logger.error(e);
}
catch(Exception e)
{
Logger.error("Unknown exception while installing package");
Logger.error(e);
}
}
< /code>
Вот получатель вещания, который обрабатывает намерение: < /p>
private BroadcastReceiver mInstallReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Logger.debug("Received intent");
Logger.debug("Intent action: " + intent.getAction());
int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE);
Logger.debug("Intent status: " + status);
String message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE);
Logger.debug("Status message: " + message);
if(status == PackageInstaller.STATUS_PENDING_USER_ACTION)
{
Intent innerIntent = (Intent) intent.getParcelableExtra(Intent.EXTRA_INTENT);
startActivity(innerIntent);
}
}
};
< /code>
И вот журналы, сгенерированные Broadcastreceiver: < /p>
11-12 15:22:08.364 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:08.365 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:08.365 7179 7179 D DummyActivity @ onReceive() Intent status: -1
11-12 15:22:08.365 7179 7179 D DummyActivity @ onReceive() Status message: null
11-12 15:22:08.378 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:08.378 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:08.379 7179 7179 D DummyActivity @ onReceive() Intent status: -1
11-12 15:22:08.379 7179 7179 D DummyActivity @ onReceive() Status message: null
11-12 15:22:08.387 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:08.387 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:08.387 7179 7179 D DummyActivity @ onReceive() Intent status: -1
11-12 15:22:08.388 7179 7179 D DummyActivity @ onReceive() Status message: null
11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Intent status: 1
11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_FAILED_INTERNAL_ERROR: Session relinquished
11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:09.156 7179 7179 D DummyActivity @ onReceive() Intent status: 1
11-12 15:22:09.156 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_FAILED_INTERNAL_ERROR: Session relinquished
11-12 15:22:09.156 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:09.157 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:09.157 7179 7179 D DummyActivity @ onReceive() Intent status: 1
11-12 15:22:09.157 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_FAILED_INTERNAL_ERROR: Session relinquished
11-12 15:22:09.214 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:09.214 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Intent status: 4
11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_PARSE_FAILED_NOT_APK: Failed parse during installPackageLI: Failed to parse /data/app/vmdl1253852664.tmp
11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Intent status: 4
11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_PARSE_FAILED_NOT_APK: Failed parse during installPackageLI: Failed to parse /data/app/vmdl1253852664.tmp
11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Received intent
11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE
11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Intent status: 4
11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_PARSE_FAILED_NOT_APK: Failed parse during installPackageLI: Failed to parse /data/app/vmdl1253852664.tmp
заранее спасибо.
Подробнее здесь:
https://stackoverflow.com/questions/648 ... linquished
1749470016
Anonymous
Я сталкиваюсь с проблемой, пытаясь установить APK с установщиком пакета. Установка не сбои с очень неясным сообщением о состоянии "install_failed_internal_error: Session Redquised". < /P> Вот код, который устанавливает пакет: < /p> [code]public static void installPackage(Context context, String packageName, String apkPath) { Logger.debug("Installing package " + apkPath); PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller(); PackageInstaller.SessionParams params = new PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL); params.setAppPackageName(packageName); try { Logger.debug("Creating session"); int sessionId = packageInstaller.createSession(params); PackageInstaller.Session session = packageInstaller.openSession(sessionId); Logger.debug("Copying buffer"); OutputStream out = session.openWrite(packageName, 0, -1); FileInputStream fileInputStream = new FileInputStream(new File(apkPath)); byte[] buffer = new byte[1024]; int len = fileInputStream.read(buffer); while(len != -1) { out.write(buffer,0, len); len = fileInputStream.read(buffer); } session.fsync(out); fileInputStream.close(); out.close(); Logger.debug("Buffer copied, sending intent"); Intent intent = new Intent(INSTALL_COMPLETE_ACTION); IntentSender intentSender = PendingIntent.getBroadcast(context, sessionId, intent, 0) .getIntentSender(); session.commit(intentSender); session.close(); } catch(IOException e) { Logger.error("IOException while installing package"); Logger.error(e); } catch(Exception e) { Logger.error("Unknown exception while installing package"); Logger.error(e); } } < /code> Вот получатель вещания, который обрабатывает намерение: < /p> private BroadcastReceiver mInstallReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Logger.debug("Received intent"); Logger.debug("Intent action: " + intent.getAction()); int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE); Logger.debug("Intent status: " + status); String message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE); Logger.debug("Status message: " + message); if(status == PackageInstaller.STATUS_PENDING_USER_ACTION) { Intent innerIntent = (Intent) intent.getParcelableExtra(Intent.EXTRA_INTENT); startActivity(innerIntent); } } }; < /code> И вот журналы, сгенерированные Broadcastreceiver: < /p> 11-12 15:22:08.364 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:08.365 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:08.365 7179 7179 D DummyActivity @ onReceive() Intent status: -1 11-12 15:22:08.365 7179 7179 D DummyActivity @ onReceive() Status message: null 11-12 15:22:08.378 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:08.378 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:08.379 7179 7179 D DummyActivity @ onReceive() Intent status: -1 11-12 15:22:08.379 7179 7179 D DummyActivity @ onReceive() Status message: null 11-12 15:22:08.387 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:08.387 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:08.387 7179 7179 D DummyActivity @ onReceive() Intent status: -1 11-12 15:22:08.388 7179 7179 D DummyActivity @ onReceive() Status message: null 11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Intent status: 1 11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_FAILED_INTERNAL_ERROR: Session relinquished 11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:09.155 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:09.156 7179 7179 D DummyActivity @ onReceive() Intent status: 1 11-12 15:22:09.156 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_FAILED_INTERNAL_ERROR: Session relinquished 11-12 15:22:09.156 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:09.157 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:09.157 7179 7179 D DummyActivity @ onReceive() Intent status: 1 11-12 15:22:09.157 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_FAILED_INTERNAL_ERROR: Session relinquished 11-12 15:22:09.214 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:09.214 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Intent status: 4 11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_PARSE_FAILED_NOT_APK: Failed parse during installPackageLI: Failed to parse /data/app/vmdl1253852664.tmp 11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:09.215 7179 7179 D DummyActivity @ onReceive() Intent status: 4 11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_PARSE_FAILED_NOT_APK: Failed parse during installPackageLI: Failed to parse /data/app/vmdl1253852664.tmp 11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Received intent 11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Intent action: net.test.INSTALL_COMPLETE 11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Intent status: 4 11-12 15:22:09.216 7179 7179 D DummyActivity @ onReceive() Status message: INSTALL_PARSE_FAILED_NOT_APK: Failed parse during installPackageLI: Failed to parse /data/app/vmdl1253852664.tmp [/code] заранее спасибо. Подробнее здесь: [url]https://stackoverflow.com/questions/64817692/android-packageinstaller-install-failed-internal-error-session-relinquished[/url]
0 Ответы
6 Просмотры
Последнее сообщение Anonymous
14 мар 2025, 00:03
0 Ответы
6 Просмотры
Последнее сообщение Anonymous
22 июл 2025, 20:53
0 Ответы
4 Просмотры
Последнее сообщение Anonymous
14 авг 2025, 00:54
0 Ответы
22 Просмотры
Последнее сообщение Anonymous
07 июл 2025, 08:55
0 Ответы
20 Просмотры
Последнее сообщение Anonymous
07 июл 2025, 09:50