我正在用Cordova制作一个需要cordova相机插件和cordova MFP插件的应用程序。在调试模式下,我的相机可以正常工作。但是,一旦我构建了该应用程序的发行版,相机将无法再使用,并且每次都会出现错误。我正在运行Cordova 6.5.0版,并且已安装的Android平台是6.3.0版。我还要提及的是,我基本上没有做任何更改涉及给我的Java代码的事情。我所做的一切都是纯JS。
奇怪的是,当未安装MFP时,该应用程序的相机在发行时可以正常运行。因此,每当我执行“ cordova插件添加cordova-plugin-mfp”时,相机仅会在发行版中损坏。这是我得到的错误:
attempt to invoke virtual method android.content.res.XMLResourceParser android.content.pm.PackageItemInfo.loadXmlMetaData(android.content.pm.Packagemanager, java.lang.String) on a null object
这是我的插件列表:
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-mfp 8.0.2018090311 "IBM MobileFirst Platform Foundation"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-okhttp 2.0.0 "OkHttp"
cordova-plugin-spinner 1.1.0 "Spinner Plugin"
cordova-plugin-whitelist 1.3.3 "Whitelist"
我一直在使用我的AndroidManifest文件,因为我一直在尝试遵循在网上找到的解决方案。这是我的AndroidManifest文件:
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="10000" android:versionName="1.0.0" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<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" />
<uses-permission android:name="android.permission.CAMERA" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:name="com.ibm.MFPApplication" 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="android.support.v4.content.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
</provider>
<activity android:name="com.worklight.wlclient.ui.UIActivity" />
<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>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
这几乎是我的config.xml文件的全部,我不能共享它的顶部,但是我可以共享它的95%:
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-dialogs" />
<plugin name="cordova-plugin-camera" />
<plugin name="cordova-plugin-spinner" />
<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">
<preference name="loadUrlTimeoutValue" value="700000" />
<allow-intent href="market:*" />
<icon src="res/icon/android/icon-96-xhdpi.png" />
<icon density="ldpi" src="res/icon/android/icon-36-ldpi.png" />
<icon density="mdpi" src="res/icon/android/icon-48-mdpi.png" />
<icon density="hdpi" src="res/icon/android/icon-72-hdpi.png" />
<icon density="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />
<icon density="xxhdpi" src="res/icon/android/icon-144-xxhdpi.png" />
<icon density="xxxhdpi" src="res/icon/android/icon-192-xxxhdpi.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<mfp:android>
<mfp:sdkChecksum>3198985637</mfp:sdkChecksum>
<mfp:appChecksum>0</mfp:appChecksum>
<mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
</mfp:security>
</mfp:android>
<mfp:ios>
<mfp:sdkChecksum>0</mfp:sdkChecksum>
<mfp:appChecksum>0</mfp:appChecksum>
<mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
</mfp:security>
</mfp:ios>
<mfp:windows>
<mfp:windows8>
<mfp:sdkChecksum>0</mfp:sdkChecksum>
<mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
</mfp:security>
</mfp:windows8>
<mfp:windowsphone8>
<mfp:sdkChecksum>0</mfp:sdkChecksum>
<mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
</mfp:security>
</mfp:windowsphone8>
<mfp:windows10>
<mfp:sdkChecksum>0</mfp:sdkChecksum>
<mfp:security>
<mfp:testWebResourcesChecksum enabled="false" ignoreFileExtensions="png, jpg, jpeg, gif, mp4, mp3" />
</mfp:security>
</mfp:windows10>
<mfp:appChecksum>0</mfp:appChecksum>
</mfp:windows>
<mfp:platformVersion>8.0.0.00-20180903-073102</mfp:platformVersion>
<mfp:clientCustomInit enabled="false" />
<mfp:server runtime="mfp" url="http://10.0.0.1:9080" />
<mfp:directUpdateAuthenticityPublicKey />
<mfp:languagePreferences>en</mfp:languagePreferences>
因此,我开始失去理智。请帮我。调试标志,MFFP和摄像头一定存在某种错误,我不知道如何解决。
答案 0 :(得分:0)
删除插件
cordova-plugin-mfp
下一步,添加相机插件,然后再次添加 mfp 插件。
现在它应该可以正常工作了。