Update Contact Causes Android to crash


#1

Disclaimers… Now I know that this is likely something that is better answered by either the Cordova team or perhaps the android team itself, but I was wondering if anyone had seen this before. Additionally the cordova-contacts-plugin is deprecated, so I am not expecting too much help there.

I have an application that provides some tools for contact management. I can read contacts no problem, I can even add contacts fairly easily. When I attempt to update a contact that I just created by adding a new phone number of email address and attempt to save the contact again, my application crashes.

Looking at the logcat of when my application was killed by android I see the exceptions below.
I have had this happen on Android 5.0.1 and Android 7.0, so I am guessing it will happen on all versions.
I have also had this result with cordova-contacts-plugin@2.3.1 and cordova-contacts-plugin@3.0.1.

Any ideas?

First Exception:

java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
        at com.android.providers.contacts.ContactsProvider2.insertData(ContactsProvider2.java:5282)
        at com.android.providers.contacts.ContactsProvider2.insertInTransaction(ContactsProvider2.java:4378)
        at com.android.providers.contacts.AbstractContactsProvider.insert(AbstractContactsProvider.java:181)
        at com.android.providers.contacts.ContactsProvider2.insert(ContactsProvider2.java:3526)
        at android.content.ContentProviderOperation.apply(ContentProviderOperation.java:302)
        at com.android.providers.contacts.AbstractContactsProvider.applyBatch(AbstractContactsProvider.java:286)
        at com.android.providers.contacts.ContactsProvider2.applyBatch(ContactsProvider2.java:3809)
        at android.content.ContentProvider$Transport.applyBatch(ContentProvider.java:320)
        at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:192)
        at android.os.Binder.execTransact(Binder.java:573)

Second Exception -

FATAL EXCEPTION: pool-1-thread-1
 java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
        at android.os.Parcel.readException(Parcel.java:1699)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
        at android.database.DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(DatabaseUtils.java:158)
        at android.content.ContentProviderProxy.applyBatch(ContentProviderNative.java:520)
        at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:438)
        at android.content.ContentResolver.applyBatch(ContentResolver.java:1319)
        at org.apache.cordova.contacts.ContactAccessorSdk5.modifyContact(ContactAccessorSdk5.java:1534)
        at org.apache.cordova.contacts.ContactAccessorSdk5.save(ContactAccessorSdk5.java:1071)
        at org.apache.cordova.contacts.ContactManager$2.run(ContactManager.java:186)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:762)