Cordova应用在Mi A1手机无法正常运行的技术求助
Hey there, sorry to hear your Cordova app's misbehaving on the Mi A1 while working flawlessly on every other device. Let’s walk through some targeted troubleshooting steps since the Mi A1’s Android One background (it runs stock Android 9 Pie as its final official update) can introduce unique quirks:
The Mi A1’s last official update is Android 9 Pie, so mismatched target SDKs or outdated Cordova tools are a common culprit:
- Check your
config.xmlforandroid-targetSdkVersion— if it’s set to 29 or higher, try dropping it to 28 (the SDK version for Android 9) to rule out compatibility gaps - Run
cordova platform lsto check your Android platform version. Old versions like cordova-android@7.x might struggle with Android 9; upgrade to cordova-android@8.x (a stable release for Pie) or a compatible newer version
Stock Android’s permission model is stricter than some custom skins, so missing permissions could block your app:
- Manually go to Settings > Apps > [Your App] > Permissions and ensure all required permissions (storage, camera, location, etc.) are enabled — sometimes users accidentally deny permissions, and Cordova doesn’t re-prompt automatically
- Audit your
config.xmlto confirm all necessary<uses-permission>tags are present (e.g.,<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />for file access)
Without logs, you’re guessing — here’s how to get them from the Mi A1:
- Enable USB Debugging on the phone: Go to Settings > About Phone and tap the build number 7 times to unlock Developer Options, then toggle on USB Debugging
- Connect the phone to your computer and run
adb logcat | grep -i "cordova\|your-app-package-name"to filter relevant logs. Look forAndroidRuntimeerrors (if the app crashes on launch) or WebView load failures - If you don’t have
adbset up, you can also use Android Studio’s Logcat tool to capture real-time logs
The Mi A1 uses Chrome WebView, which might be outdated or have strict defaults:
- Open Google Play on the Mi A1 and update Android System WebView — old versions can break compatibility with modern Cordova JS APIs
- Try adding WebView preferences to
config.xmlto bypass common issues:<preference name="AndroidInsecureFileModeEnabled" value="true" />(if your app loads local files)<preference name="WebViewBounce" value="false" />(to disable bounce behavior that might cause crashes on stock Android)
Some Cordova plugins don’t play nice with stock Android 9:
- Create a minimal Cordova test project (only core plugins) and see if it runs on the Mi A1. If it works, add your app’s plugins one by one to identify which one is causing the problem
- Check the GitHub issues page for any problematic plugins — other users might have reported Mi A1 or Android 9-specific bugs, and there might be fixes or workarounds available
Incorrectly packaged or signed APKs can fail to run on stock Android:
- Ensure you’re using a proper release signature for your APK. Debug-signed APKs sometimes get blocked by stock Android’s security checks
- Uninstall any existing versions of your app on the Mi A1 before installing the test build — version code conflicts can cause unexpected crashes
内容的提问来源于stack exchange,提问作者Thom

