gpt4 book ai didi

android - ionic 相机尝试调用虚拟方法

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:17:17 26 4
gpt4 key购买 nike

我们为 Ionic 安装了相机插件,但遇到了这个错误:

Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference

我们已经尝试了所有提供的解决方案 link我们该如何解决?我们的(原始) list 是:

 <?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" 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/icon" 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>
<service android:enabled="true" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementService" />
<service android:name="org.apache.cordova.firebase.FirebasePluginMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="org.apache.cordova.firebase.FirebasePluginInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<receiver android:name="org.apache.cordova.firebase.OnNotificationOpenReceiver" />
</application>
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

11 月 20 日:为了进一步解释,我们在代码中附加了 Camera 调用。第一个函数成功打开具有指定 sourceType 的图库。第二个函数失败,源类型为 CAMERA,出现上述错误。我们在同一个项目中使用插件 QR 扫描仪,相机打开并正常运行。

openGallery () {
let cameraOptions = {
sourceType: this.Camera.PictureSourceType.PHOTOLIBRARY,
destinationType: this.Camera.DestinationType.DATA_URL,
quality: 100,
targetWidth: 1000,
targetHeight: 1000,
encodingType: this.Camera.EncodingType.JPEG,
correctOrientation: true
}
this.Camera.getPicture(cameraOptions)
.then(imageData => {
this.base64Image = 'data:image/jpeg;base64,' + imageData;
err => console.log(err);});


}

takePhoto() {
let cameraOptions = {
sourceType: this.Camera.PictureSourceType.CAMERA,
destinationType: this.Camera.DestinationType.FILE_URI,
quality: 100,
targetWidth: 1000,
targetHeight: 1000,
encodingType: this.Camera.EncodingType.JPEG,
correctOrientation: true,
}
this.Camera.getPicture(cameraOptions)
.then(file_uri => {
console.log(file_uri);
},
err => console.log(err));


}

最佳答案

将此行添加到您的混淆器规则

-keep class com.abc.xyz.BuildConfig { *; }

com.abc.xyz 是你的包名

关于android - ionic 相机尝试调用虚拟方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53327571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com