插件加载多次并且构建过程失败
Plugins loaded multiple times and build processes fails
出于某种原因,我发现我的 phonegap 项目产生了很多不同,包括缺乏构建能力。
我有以下配置:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.qrreader" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>My Example QR Reader</name>
<description>
Example QR Reader
</description>
<author email="me@example.com" href="http://example.com">
Repox
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-build-tool" value="gradle" />
<preference name="orientation" value="portrait" />
<plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />
<plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
<plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<plugin name="phonegap-plugin-barcodescanner" spec="~6.0.6" />
<plugin name="cordova-plugin-qrscanner" spec="~2.5.0" />
<icon src="www/res/icon.png" />
<icon gap:platform="ios" height="60" src="www/res/icons/ios/icon-60.png" width="60" />
<icon gap:platform="ios" height="120" src="www/res/icons/ios/icon-60-2x.png" width="120" />
<icon gap:platform="ios" height="180" src="www/res/icons/ios/icon-60-3x.png" width="180" />
<icon gap:platform="ios" height="76" src="www/res/icons/ios/icon-76.png" width="76" />
<icon gap:platform="ios" height="152" src="www/res/icons/ios/icon-76-2x.png" width="152" />
<icon gap:platform="ios" height="40" src="www/res/icons/ios/icon-40.png" width="40" />
<icon gap:platform="ios" height="80" src="www/res/icons/ios/icon-40-2x.png" width="80" />
<icon gap:platform="ios" height="57" src="www/res/icons/ios/icon-57.png" width="57" />
<icon gap:platform="ios" height="114" src="www/res/icons/ios/icon-57-2x.png" width="114" />
<icon gap:platform="ios" height="72" src="www/res/icons/ios/icon-72.png" width="72" />
<icon gap:platform="ios" height="144" src="www/res/icons/ios/icon-72-2x.png" width="144" />
<icon gap:platform="ios" height="29" src="www/res/icons/ios/icon-small.png" width="29" />
<icon gap:platform="ios" height="58" src="www/res/icons/ios/icon-small-2x.png" width="58" />
<icon gap:platform="ios" height="50" src="www/res/icons/ios/icon-50.png" width="50" />
<icon gap:platform="ios" height="100" src="www/res/icons/ios/icon-50-2x.png" width="100" />
<icon gap:platform="android" gap:qualifier="ldpi" src="www/res/icons/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="www/res/icons/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="www/res/icons/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="www/res/icons/android/icon-96-xhdpi.png" />
<icon gap:platform="android" gap:qualifier="xxhdpi" src="www/res/icons/android/icon-144-xxhdpi.png" />
<icon gap:platform="android" gap:qualifier="xxxhdpi" src="www/res/icons/android/icon-192-xxxhdpi.png" />
<splash src="www/res/splash.png" />
<splash gap:platform="ios" height="480" src="www/res/screens/ios/screen-iphone-portrait.png" width="320" />
<splash gap:platform="ios" height="960" src="www/res/screens/ios/screen-iphone-portrait-2x.png" width="640" />
<splash gap:platform="ios" height="1024" src="www/res/screens/ios/screen-ipad-portrait.png" width="768" />
<splash gap:platform="ios" height="2048" src="www/res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash gap:platform="ios" height="768" src="www/res/screens/ios/screen-ipad-landscape.png" width="1024" />
<splash gap:platform="ios" height="1536" src="www/res/screens/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash gap:platform="ios" height="1136" src="www/res/screens/ios/screen-iphone-568h-2x.png" width="640" />
<splash gap:platform="ios" height="1334" src="www/res/screens/ios/screen-iphone-portrait-667h.png" width="750" />
<splash gap:platform="ios" height="2208" src="www/res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />
<splash gap:platform="ios" height="1242" src="www/res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />
<splash gap:platform="android" gap:qualifier="land-hdpi" src="www/res/screens/android/screen-hdpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="land-ldpi" src="www/res/screens/android/screen-ldpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="land-mdpi" src="www/res/screens/android/screen-mdpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="land-xhdpi" src="www/res/screens/android/screen-xhdpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="port-hdpi" src="www/res/screens/android/screen-hdpi-portrait.png" />
<splash gap:platform="android" gap:qualifier="port-ldpi" src="www/res/screens/android/screen-ldpi-portrait.png" />
<splash gap:platform="android" gap:qualifier="port-mdpi" src="www/res/screens/android/screen-mdpi-portrait.png" />
<splash gap:platform="android" gap:qualifier="port-xhdpi" src="www/res/screens/android/screen-xhdpi-portrait.png" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<gap:config-file platform="ios" parent="NSCameraUsageDescription" overwrite="true">
<string>To read QR codes</string>
</gap:config-file>
</widget>
使用普通示例 HTML 文件,控制台告诉我我的应用程序正在尝试多次加载 cordova 插件:
...
Uncaught module cordova-plugin-vibration.notification already defined
define @ cordova.js:79
(anonymous) @ vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.notification already defined
define @ cordova.js:79
(anonymous) @ vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-qrscanner.QRScanner already defined
define @ cordova.js:79
(anonymous) @ www.min.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module cordova-plugin-qrscanner.QRScannerProxy already defined
define @ cordova.js:79
(anonymous) @ plugin.min.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
....
我怀疑这些事情也会导致我的构建失败;我无法再通过 Phonegap Build 构建我的 IOS 或 Android 应用程序。
android 构建的日志说明如下:
构建失败
Total time: 13.921 secs
Error: /project/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/project/AndroidManifest.xml:31:5-90 Error:
Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:31:5-90 duplicated with element declared at AndroidManifest.xml:28:5-65
/project/AndroidManifest.xml:32:5-85 Error:
Element uses-feature#android.hardware.camera at AndroidManifest.xml:32:5-85 duplicated with element declared at AndroidManifest.xml:30:5-84
/project/AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
我不知道去哪里寻找我的问题的解决方案;我不明白为什么模块会尝试加载多次,也不明白构建突然失败的原因。
From searching around, it appears as though you've stumbled upon an interesting Android issue。基本上,两个或多个引用的插件正在向 AndroidManifest.xml 文件添加重复的权限条目,类似于:
<uses-permission android:name="android.permission.CAMERA" />
遗憾的是,由于您使用的是 PhoneGap Build,因此无法编辑 AndroidManifest 文件。使用上面的配置,我能够通过删除 Barcode Scanner 插件行成功构建:
<plugin name="phonegap-plugin-barcodescanner" spec="~6.0.6" />
我猜 QR Scanner 和 Camera 插件也指定了 CAMERA 权限。你需要这三个吗?一个插件可能会捆绑其他插件的功能。否则,您需要分叉插件、更新其 AndroidManifest 权限并重新编译它们 - 这不是一件容易的事。
出于某种原因,我发现我的 phonegap 项目产生了很多不同,包括缺乏构建能力。
我有以下配置:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.qrreader" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>My Example QR Reader</name>
<description>
Example QR Reader
</description>
<author email="me@example.com" href="http://example.com">
Repox
</author>
<content src="index.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="14" />
<preference name="android-build-tool" value="gradle" />
<preference name="orientation" value="portrait" />
<plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />
<plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
<plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
<plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
<plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
<plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
<plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
<plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
<plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
<plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
<plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
<plugin name="phonegap-plugin-barcodescanner" spec="~6.0.6" />
<plugin name="cordova-plugin-qrscanner" spec="~2.5.0" />
<icon src="www/res/icon.png" />
<icon gap:platform="ios" height="60" src="www/res/icons/ios/icon-60.png" width="60" />
<icon gap:platform="ios" height="120" src="www/res/icons/ios/icon-60-2x.png" width="120" />
<icon gap:platform="ios" height="180" src="www/res/icons/ios/icon-60-3x.png" width="180" />
<icon gap:platform="ios" height="76" src="www/res/icons/ios/icon-76.png" width="76" />
<icon gap:platform="ios" height="152" src="www/res/icons/ios/icon-76-2x.png" width="152" />
<icon gap:platform="ios" height="40" src="www/res/icons/ios/icon-40.png" width="40" />
<icon gap:platform="ios" height="80" src="www/res/icons/ios/icon-40-2x.png" width="80" />
<icon gap:platform="ios" height="57" src="www/res/icons/ios/icon-57.png" width="57" />
<icon gap:platform="ios" height="114" src="www/res/icons/ios/icon-57-2x.png" width="114" />
<icon gap:platform="ios" height="72" src="www/res/icons/ios/icon-72.png" width="72" />
<icon gap:platform="ios" height="144" src="www/res/icons/ios/icon-72-2x.png" width="144" />
<icon gap:platform="ios" height="29" src="www/res/icons/ios/icon-small.png" width="29" />
<icon gap:platform="ios" height="58" src="www/res/icons/ios/icon-small-2x.png" width="58" />
<icon gap:platform="ios" height="50" src="www/res/icons/ios/icon-50.png" width="50" />
<icon gap:platform="ios" height="100" src="www/res/icons/ios/icon-50-2x.png" width="100" />
<icon gap:platform="android" gap:qualifier="ldpi" src="www/res/icons/android/icon-36-ldpi.png" />
<icon gap:platform="android" gap:qualifier="mdpi" src="www/res/icons/android/icon-48-mdpi.png" />
<icon gap:platform="android" gap:qualifier="hdpi" src="www/res/icons/android/icon-72-hdpi.png" />
<icon gap:platform="android" gap:qualifier="xhdpi" src="www/res/icons/android/icon-96-xhdpi.png" />
<icon gap:platform="android" gap:qualifier="xxhdpi" src="www/res/icons/android/icon-144-xxhdpi.png" />
<icon gap:platform="android" gap:qualifier="xxxhdpi" src="www/res/icons/android/icon-192-xxxhdpi.png" />
<splash src="www/res/splash.png" />
<splash gap:platform="ios" height="480" src="www/res/screens/ios/screen-iphone-portrait.png" width="320" />
<splash gap:platform="ios" height="960" src="www/res/screens/ios/screen-iphone-portrait-2x.png" width="640" />
<splash gap:platform="ios" height="1024" src="www/res/screens/ios/screen-ipad-portrait.png" width="768" />
<splash gap:platform="ios" height="2048" src="www/res/screens/ios/screen-ipad-portrait-2x.png" width="1536" />
<splash gap:platform="ios" height="768" src="www/res/screens/ios/screen-ipad-landscape.png" width="1024" />
<splash gap:platform="ios" height="1536" src="www/res/screens/ios/screen-ipad-landscape-2x.png" width="2048" />
<splash gap:platform="ios" height="1136" src="www/res/screens/ios/screen-iphone-568h-2x.png" width="640" />
<splash gap:platform="ios" height="1334" src="www/res/screens/ios/screen-iphone-portrait-667h.png" width="750" />
<splash gap:platform="ios" height="2208" src="www/res/screens/ios/screen-iphone-portrait-736h.png" width="1242" />
<splash gap:platform="ios" height="1242" src="www/res/screens/ios/screen-iphone-landscape-736h.png" width="2208" />
<splash gap:platform="android" gap:qualifier="land-hdpi" src="www/res/screens/android/screen-hdpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="land-ldpi" src="www/res/screens/android/screen-ldpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="land-mdpi" src="www/res/screens/android/screen-mdpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="land-xhdpi" src="www/res/screens/android/screen-xhdpi-landscape.png" />
<splash gap:platform="android" gap:qualifier="port-hdpi" src="www/res/screens/android/screen-hdpi-portrait.png" />
<splash gap:platform="android" gap:qualifier="port-ldpi" src="www/res/screens/android/screen-ldpi-portrait.png" />
<splash gap:platform="android" gap:qualifier="port-mdpi" src="www/res/screens/android/screen-mdpi-portrait.png" />
<splash gap:platform="android" gap:qualifier="port-xhdpi" src="www/res/screens/android/screen-xhdpi-portrait.png" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<gap:config-file platform="ios" parent="NSCameraUsageDescription" overwrite="true">
<string>To read QR codes</string>
</gap:config-file>
</widget>
使用普通示例 HTML 文件,控制台告诉我我的应用程序正在尝试多次加载 cordova 插件:
...
Uncaught module cordova-plugin-vibration.notification already defined
define @ cordova.js:79
(anonymous) @ vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.notification already defined
define @ cordova.js:79
(anonymous) @ vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-vibration.Vibration already defined
define @ cordova.js:79
(anonymous) @ Vibration.js:1
cordova.js:79 Uncaught module cordova-plugin-qrscanner.QRScanner already defined
define @ cordova.js:79
(anonymous) @ www.min.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScanner already defined
define @ cordova.js:79
(anonymous) @ barcodescanner.js:1
cordova.js:79 Uncaught module cordova-plugin-qrscanner.QRScannerProxy already defined
define @ cordova.js:79
(anonymous) @ plugin.min.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
define @ cordova.js:79
(anonymous) @ BarcodeScannerProxy.js:1
cordova.js:79 Uncaught module phonegap-plugin-barcodescanner.BarcodeScannerProxy already defined
....
我怀疑这些事情也会导致我的构建失败;我无法再通过 Phonegap Build 构建我的 IOS 或 Android 应用程序。
android 构建的日志说明如下:
构建失败
Total time: 13.921 secs
Error: /project/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/project/AndroidManifest.xml:31:5-90 Error:
Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:31:5-90 duplicated with element declared at AndroidManifest.xml:28:5-65
/project/AndroidManifest.xml:32:5-85 Error:
Element uses-feature#android.hardware.camera at AndroidManifest.xml:32:5-85 duplicated with element declared at AndroidManifest.xml:30:5-84
/project/AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
我不知道去哪里寻找我的问题的解决方案;我不明白为什么模块会尝试加载多次,也不明白构建突然失败的原因。
From searching around, it appears as though you've stumbled upon an interesting Android issue。基本上,两个或多个引用的插件正在向 AndroidManifest.xml 文件添加重复的权限条目,类似于:
<uses-permission android:name="android.permission.CAMERA" />
遗憾的是,由于您使用的是 PhoneGap Build,因此无法编辑 AndroidManifest 文件。使用上面的配置,我能够通过删除 Barcode Scanner 插件行成功构建:
<plugin name="phonegap-plugin-barcodescanner" spec="~6.0.6" />
我猜 QR Scanner 和 Camera 插件也指定了 CAMERA 权限。你需要这三个吗?一个插件可能会捆绑其他插件的功能。否则,您需要分叉插件、更新其 AndroidManifest 权限并重新编译它们 - 这不是一件容易的事。