Ionic 3中Barcode Scan与Camera插件冲突及AndroidManifest重复问题求助
Hey there, let’s work through this plugin conflict and deprecated API warning issue together. I’ve dealt with similar Ionic plugin compatibility headaches before, so here’s a structured approach to fix things:
1. Fix Plugin Version Compatibility First
The most common cause of plugin conflicts is mismatched versions between @ionic-native wrappers and their underlying Cordova plugins. Make sure:
- Your
@ionic-native/cameraand@ionic-native/barcode-scannerversions match (they should align with your Ionic framework version—e.g., if you’re on Ionic 5, use^5.x.xfor both) - The Cordova plugins (
cordova-plugin-cameraandphonegap-plugin-barcodescanner) are updated to their latest stable versions that support your target Android SDK.
Run these commands to check and update:
# List installed plugins to verify versions ionic cordova plugin list # Update Camera plugin ionic cordova plugin update cordova-plugin-camera # Update Barcode Scanner plugin ionic cordova plugin update phonegap-plugin-barcodescanner # Update Ionic Native wrappers npm install @ionic-native/camera@latest @ionic-native/barcode-scanner@latest
2. Stop Manually Editing Plugin Files (Fix the Root Conflict)
Manually deleting the <uses-feature> line in barcodescanner/plugin.xml isn’t a sustainable fix—it breaks the plugin’s intended configuration and leads to secondary issues like the deprecated API warning. Instead, let Cordova handle permission merging properly:
- Revert any manual edits you made to
barcodescanner/plugin.xml(restore the original file if you have a backup, or reinstall the plugin to reset it) - Add a single, unified camera feature declaration in your project’s
config.xmlfile. This will override duplicate declarations from both plugins:
<platform name="android"> <!-- Centralize camera feature requirement --> <uses-feature android:name="android.hardware.camera" android:required="true"/> <!-- Ensure camera permissions are present --> <uses-permission android:name="android.permission.CAMERA"/> </platform>
3. Resolve the "Deprecated API" Warning
This warning pops up because one (or both) plugins are using outdated Android SDK methods. Here’s how to address it:
Option A: Update Plugin Versions
As mentioned earlier, updating to the latest plugin versions often fixes deprecated API usage. If updates don’t resolve it, check the plugin’s GitHub repo to see if there’s a known issue or a beta version that supports newer Android SDKs.
Option B: Adjust Android Build Configuration
If updating plugins isn’t possible, tweak your project’s Android build settings to suppress the warning (or target a compatible SDK):
- Open
platforms/android/build.gradle - Update the
compileSdkVersionandtargetSdkVersionto a recent stable version (e.g., 33):
android { compileSdkVersion 33 defaultConfig { targetSdkVersion 33 // ... other existing settings } }
- Add lint options to ignore deprecated API warnings (only do this if you can’t update plugins):
android { // ... existing config lintOptions { disable 'DeprecatedApi' } }
4. Clean and Rebuild Your Project
Cache or leftover build files often cause weird issues after plugin changes. Run these commands to start fresh:
# Remove and re-add the Android platform ionic cordova platform rm android ionic cordova platform add android # Clean and build the project ionic cordova build android --clean
If you still run into issues, double-check your CMD logs—look for specific plugin conflict errors (not just the deprecated warning) that might point to a missing dependency or version mismatch.
内容的提问来源于stack exchange,提问作者RBalconi

