Error when importing .vcf contacts with mixed vCard versions
- /e/ version: 1.12.3-s
- Developer mode enabled: no
- Device rooted: no
- Trackers blocker enabled: yes
Summary
.vcf files containing multiple contacts with mixed vCard versions fail to import into the Contacts app. Files like this may be created by exporting contacts from certain apps, e.g. desktop Thunderbird in my case.
The problem
Steps to reproduce
- Create a .vcf file with multiple contacts, containing at least 2 different vcard versions (e.g. 3.0 and 4.0). I've included a vcf_mixed.vcf file for easy testing.
- Open the Contacts app
- Open the sidebar
- Select 'Settings'
- Select 'Import'
- Select import contacts from '.vcf file'
- Select the device to import
- Select the .vcf file containing mixed vcard versions
What is the current behavior?
File fails to import. There is a "Couldn't import vCard" error popup at the bottom of the screen.
What is the expected correct behavior?
Expected behaviour would be for the contacts to be imported without error. 4.0 (and 3.0) versions are both supported individually already: e/os/android_packages_apps_Contacts!77 (db66001f)
Technical informations
Relevant logs (adb logcat
)
This seems to be the relevant part of the log:
07-26 00:22:26.361 2194 2194 I VCardImport: vCard selected for import: content://com.android.providers.media.documents/document/document%3A320
07-26 00:22:26.361 2194 2194 I VCardImport: Copy a Uri to app local storage (content://com.android.providers.media.documents/document/document%3A320 -> import_tmp_0.vcf)
07-26 00:22:26.364 3523 6281 D MediaProvider: Open with FUSE. FilePath: /storage/emulated/0/Download/vcf_mixed.vcf. Uid: 10188. Media Capabilities Uid: 0. ShouldRedact: false. ShouldTranscode: false
07-26 00:22:26.370 2194 2194 I VCardImport: Bind to VCardService.
07-26 00:22:26.435 2194 2194 I VCardImport: Connected to VCardService. Kick a vCard cache thread (uri: [file:/data/user/0/com.android.contacts/files/import_tmp_0.vcf])
07-26 00:22:26.436 2194 9904 I VCardImport: vCard cache thread starts running.
07-26 00:22:26.438 2194 9904 W vCard : Unexpected Dquote inside property.
07-26 00:22:26.438 2194 9904 W vCard : Unexpected Dquote inside property.
07-26 00:22:26.438 2194 9904 E VCardImport: Failed to cache vcard
07-26 00:22:26.438 2194 9904 E VCardImport: com.android.vcard.exception.VCardException: vCard with unspported version.
07-26 00:22:26.438 2194 9904 E VCardImport: at com.android.contacts.vcard.ImportVCardActivity$VCardCacheThread.constructImportRequest(ImportVCardActivity.java:380)
07-26 00:22:26.438 2194 9904 E VCardImport: at com.android.contacts.vcard.ImportVCardActivity$VCardCacheThread.run(ImportVCardActivity.java:257)
07-26 00:22:26.441 2194 9904 I VCardImport: Finished caching vCard.
Solutions
Workaround
Split the single file into separate files which contain only 1 vCard version each. For example, a file with all the vCard 3.0 contacts and another file with all the vCard 4.0 contacts. Then import these files separately.
Possible fixes
It looks like the code in this file would have to be reworked so it doesn't assume a single vCard version per file: https://gitlab.e.foundation/e/os/android_packages_apps_Contacts/-/blob/v1-s/src/com/android/contacts/vcard/ImportVCardActivity.java
~