Ionic Camera Попытка вызвать виртуальный метод - PullRequest
0 голосов
/ 15 ноября 2018

Мы установили Camera Plugin для 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

Мы уже опробовали все решения, представленные в ссылке Как мы можем это исправить?Наш (оригинальный) манифест:

 <?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>

20 / NOV: Чтобы пояснить подробнее, мы прикрепили вызов камеры в коде.Первая функция успешно открывает галерею с указанным sourceType.Вторая функция завершается ошибкой с исходным типом CAMERA из-за ошибки, упомянутой выше.Мы используем плагин QR Scanner в том же проекте, там камера открывается и работает.

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));   


}

1 Ответ

0 голосов
/ 29 июля 2019

Добавьте эту строку в Ваши правила proguard

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

com.abc.xyz - это имя вашего пакета

...