报错信息如下:
> Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
> Task :app:processDebugManifest FAILED
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
22 actionable tasks: 4 executed, 18 up-to-date
D:\workspace\ionic\1\ors\ors\platforms\android\gradlew: Command failed with exit code 1 Error output:
D:\workspace\ionic\1\ors\ors\platforms\android\app\src\main\AndroidManifest.xml:29:5-84 Error:
Element uses-feature#android.hardware.camera at AndroidManifest.xml:29:5-84 duplicated with element declared at AndroidManifest.xml:27:5-85
D:\workspace\ionic\1\ors\ors\platforms\android\app\src\main\AndroidManifest.xml:31:5-65 Error:
Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:31:5-65 duplicated with element declared at AndroidManifest.xml:26:5-90
D:\workspace\ionic\1\ors\ors\platforms\android\app\src\main\AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
打开 ./platform/android/app/src/AndroidManiFest.xml
可以看到有两个权限申请重复了(粗斜体);
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.ccthank" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
</provider>
<activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@style/Theme.AppCompat.Light" />
<provider android:authorities="${applicationId}.appupdate.provider" android:exported="false" android:grantUriPermissions="true" android:name="com.vaenow.appupdate.android.GenericFileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/appupdate_paths" />
</provider>
<activity android:name="com.cordovaplugincamerapreview.CameraActivity" android:screenOrientation="portrait" android:theme="@style/CameraPreviewTheme" />
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
</manifest>
但是这直接在这里删除重新build或者runandroid并不生效。因为这个问题是在加入Camera Preview后产生的,
打开./plugins/cordova-plugin-camera-preview/plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<plugin id="cordova-plugin-camera-preview" version="0.10.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-camera-preview</name>
<description>Cordova plugin that allows camera interaction from HTML code. Show camera preview popup on top of the HTML.</description>
<license>Apache 2.0</license>
<keywords>cordova,phonegap,ecosystem:cordova,cordova-android,cordova-ios,android,ios,ionic,camera,cam,camera-preview,preview</keywords>
<repo>https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git</repo>
<issue>https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview/issues</issue>
<js-module src="www/CameraPreview.js" name="CameraPreview">
<clobbers target="CameraPreview" />
</js-module>
<platform name="android">
<source-file src="src/android/CameraPreview.java" target-dir="src/com/cordovaplugincamerapreview" />
<source-file src="src/android/CameraActivity.java" target-dir="src/com/cordovaplugincamerapreview" />
<source-file src="src/android/CustomSurfaceView.java" target-dir="src/com/cordovaplugincamerapreview" />
<source-file src="src/android/Preview.java" target-dir="src/com/cordovaplugincamerapreview" />
<source-file src="src/android/TapGestureDetector.java" target-dir="src/com/cordovaplugincamerapreview" />
<source-file src="src/android/camera_activity.xml" target-dir="res/layout" />
<source-file src="src/android/camera_theme.xml" target-dir="res/values" />
<source-file src="src/android/camera_ids.xml" target-dir="res/values" />
<framework src="com.android.support:exifinterface:25+" />
<config-file target="res/xml/config.xml" parent="/*">
<feature name="CameraPreview">
<param name="android-package" value="com.cordovaplugincamerapreview.CameraPreview" />
<param name="onload" value="true" />
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest">
<uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.cordovaplugincamerapreview.CameraActivity" android:screenOrientation="portrait" android:theme="@style/CameraPreviewTheme" />
</config-file>
</platform>
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="CameraPreview">
<param name="ios-package" value="CameraPreview" onload="true" />
</feature>
</config-file>
<header-file src="src/ios/CameraPreview.h" />
<source-file src="src/ios/CameraPreview.m" />
<header-file src="src/ios/TemperatureAndTint.h" />
<source-file src="src/ios/TemperatureAndTint.m" />
<header-file src="src/ios/CameraSessionManager.h" />
<source-file src="src/ios/CameraSessionManager.m" />
<header-file src="src/ios/CameraRenderController.h" />
<source-file src="src/ios/CameraRenderController.m" />
<framework src="ImageIO.framework" weak="true" />
<framework src="MobileCoreServices.framework" />
<framework src="CoreLocation.framework" />
<framework src="CoreGraphics.framework" />
<framework src="AssetsLibrary.framework" />
<framework src="CoreGraphics.framework" />
<framework src="CoreImage.framework" />
<framework src="OpenGLES.framework" />
<framework src="GLKit.framework" />
<framework src="CoreVideo.framework" />
<framework src="QuartzCore.framework"/>
</platform>
</plugin>
删除两行粗斜体。ionic3可以直接ionic cordova build|android android 问题就解决了,
ionic4 需要ionic cordova platform remove android -> ionic cordova platform add android
然后ionic cordova build|android android ;
转载请标明出处。