I created a test application for installing apk files. PackageInstaller was used for this. The app works well. However, for Xiaomi in BroadcastReceiver I get the "INSTALL_FAILED_INTERNAL_ERROR: Permission Denied" error. But if you enable developer mode and disable MIUI optimization, then the application also successfully installs packages. I can't get users of my application to force them to turn off the optimization mode, how can I deal with this? Tested on MIUI 11 version
PackageInstaller does not work on MIUI optimization mode
846 views Asked by Serg Sergeevich At
2
There are 2 answers
0
On
You can detect whether user has MIUI and optimization mode enabled and display a message which will force user to disable it. Use these utility methods (it's a part of Split APKs Installer source code): https://github.com/Aefyr/SAI/blob/master/app/src/main/java/com/aefyr/sai/utils/MiuiUtils.java
It seems as though MIUI 20.2.20 solves this incompatibility. solru's answer checks for this.
In case the GitHub link stops working:
Ultimately the functions you're looking for are
isMiui
andisMiuiFixed
.