Ionic3推送功能真机报错:Push插件未安装问题求助
Hey there, let's get to the bottom of this push plugin issue you're having with your Ionic 3 app. From the error logs and your description, it's clear that the phonegap-plugin-push isn't being properly added to your Android platform—even though you ran the installation command. Here are targeted steps to resolve this:
Completely reset the plugin and platform installation
Sometimes cached files or partial installs can cause this. Follow these steps in order:- Uninstall the push plugin and its corresponding npm package:
ionic cordova plugin remove phonegap-plugin-push npm uninstall @ionic-native/push @ionic-native/core - Clear npm's cache to eliminate any corrupted packages:
npm cache clean --force - Remove and re-add the Android platform to ensure a fresh state:
ionic cordova platform rm android ionic cordova platform add android - Reinstall the plugin with the correct Ionic 3-compatible version of the native wrapper:
Note: Ionic 3 requiresionic cordova plugin add phonegap-plugin-push npm install @ionic-native/push@4.x --save@ionic-nativev4.x—avoid installing newer versions as they won't be compatible.
- Uninstall the push plugin and its corresponding npm package:
Verify plugin configuration in config.xml
Open your project's rootconfig.xmlfile and check if it includes the push plugin entry. It should look something like this (adjust the version and sender ID to match your setup):<plugin name="phonegap-plugin-push" spec="~2.3.0"> <variable name="SENDER_ID" value="your-firebase-sender-id" /> </plugin>If the entry is missing, add it manually, then run
ionic cordova prepare androidto sync the changes to the Android platform.Clean up dependency files and rebuild
- Delete the
package-lock.jsonfile andnode_modulesfolder from your project root. - Run
npm installto reinstall all dependencies from scratch. - Rebuild your Android app with:
ionic cordova build android - Before installing the new build on your device, make sure to uninstall the old version of the app to avoid any caching conflicts.
- Delete the
Check build logs for hidden errors
When running the build command, keep an eye on the terminal output. If there are any errors during plugin installation (like missing dependencies or Firebase configuration issues), they'll show up here—address those first before testing on the device.
内容的提问来源于stack exchange,提问作者ULLAS K

