Skip to main content

Posts

Showing posts from February, 2026

Prevent MIUI Force Dark Mode From Breaking Your App's UI

  There are few moments more frustrating in Android development than receiving a bug report with a screenshot showing your meticulously crafted UI looking like an inverted photo negative. The user claims your app is "broken," showing white text on a white background or logos that look like X-ray scans. If the device is a Xiaomi, POCO, or Redmi running MIUI, your code likely isn't the culprit. The issue is MIUI's aggressive system-level "Dark Mode," which heuristically inverts colors on apps that do not explicitly declare Dark Theme support. This mechanism overrides your XML layout definitions and Drawables at the framework level. This guide provides the technical steps to disable this override and regain control of your application's rendering. The Root Cause: Algorithmic Color Inversion To understand the fix, we must understand the mechanism. Standard Android Dark Theme relies on the  DayNight  resource qualifiers (e.g.,  values-night ). If your app doe...

Fix "Install via USB" & "Device is temporarily restricted" on Xiaomi

  There is rarely anything more frustrating in Android development than a reliable build failing to deploy due to OEM-specific restrictions. You hit "Run" in Android Studio, wait for Gradle, and are met with   INSTALL_FAILED_USER_RESTRICTED   in the Logcat or a cryptic toast message on your Xiaomi device: "The device is temporarily restricted." This guide details exactly why MIUI (and the newer HyperOS) blocks ADB installations by default and provides the step-by-step technical solution to bypass these security layers. The Root Cause: MIUI Security vs. ADB To fix the issue, you must understand what is blocking you. In stock Android (AOSP), enabling "USB Debugging" generally grants the ADB daemon ( adbd ) permission to execute  pm install  commands to push packages to the  /data/app/  directory. Xiaomi devices running MIUI or HyperOS add a proprietary security middleware layer between the ADB daemon and the Package Manager. This layer is designed to pre...