3

I'm having an issue that I found the cause but I couldn't manage to resolve.

My cordova app crashes on android 8.0.0. I did a logcat which revealed that the app is trying to access contacts.

The weird thing is I have no plugin for contacts nor using contacts in my app.

On the logcat, I have this error:

12-11 17:29:42.094 E/AndroidRuntime( 5609): java.lang.RuntimeException: java.lang.RuntimeException: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{6155964 5609:com.pierrickmartelliere.UPHAIRR/u0a210} (pid=5609, uid=10210) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS

I tried everything, added

<config-file parent="/manifest" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" /> </config-file>

to my config.xml, it adds well on AndroidManifest.xml when building but I still got the error.

I tried both tags uses-permission and uses-permission-sdk as stated here but without luck.

My version of cordova-android is 6.2.3

I also tried the cordova-plugin-permission, as in deviceready listener:

var permissions = cordova.plugins.permissions;
    permissions.requestPermission(
      permissions.READ_CONTACTS,
      function(success) {},
      function(error) {}
    );
    permissions.requestPermission(
      permissions.WRITE_CONTACTS,
      function(success) {},
      function(error) {}
    );

But nothing changed. The app crashes before the "deviceready" event is fired so I can do nothing on runtime.

As stated here, if I change the targetSdkVersion to lower than 23 (even 25), the crash disappears, but Im' not able to upload it to google play anymore since play console doesn't accept targetSdkVersion < 26.

Also, if I manually authorize contact access from app setting and I force stop and relaunch the app, it works. This is driving me crazy.

Some help on this would be very appreciated.

Thanks to anyone who will take the time to read or answer.

Pierrick Martellière
  • 1,554
  • 3
  • 21
  • 42
  • You should not do anything that requires those permissions until the permissions actually have been granted (presumably when the `success` functions are called; I'm not familiar with that library). – Michael Dec 14 '18 at 16:41
  • Yeah bro but the issue is I cannot actually do anything before the app starts. It's liké I have no choice of console log or anything. I simply can't access any log excepting logcat, since the app is crashing before I am able to see the app in developer tool's devices category. Everything added in device ready event cathcer is simpy not executed because the app is crashing before. – Pierrick Martellière Dec 15 '18 at 01:19
  • I never said anything like this, but thanks for your useful remark. – Pierrick Martellière Dec 17 '18 at 16:14

1 Answers1

0

I finally posted an issue in the cordova-android github. I got an answer quickly, which is:

UPDATE cordova-android to 7.1.4 !

https://github.com/apache/cordova-android/issues/606

Pierrick Martellière
  • 1,554
  • 3
  • 21
  • 42
  • How did you get past the Crosswalk issue noted in the link? – RamblinRose Jan 04 '19 at 18:25
  • Updating cordova for my project is being quite problematic, a lot of things are failing, any chance that someone know how to fix this without updating cordova? Does anyone knows what was the change in that cordova version for this fix? – Matias Oct 09 '19 at 20:41