java.lang.ClassCastException after removing contact image

  • Hi,

    I’ve removed the contact images of some contacts on my phone. When DAVdroid tries to sync these changes to the remote server, I get an error.

    The debug info of the error:

    Synchronization phase: 3
    Account name: Contacts (username@domain.invalid ag)
    java.lang.ClassCastException: android.content.res.AssetFileDescriptor cannot be cast to
    	at at.bitfire.vcard4android.AndroidContact.populatePhoto(AndroidContact.kt:293)
    	at at.bitfire.vcard4android.AndroidContact.getContact(AndroidContact.kt:140)
    	at at.bitfire.davdroid.resource.LocalContact.getCachedGroupMemberships(
    	at at.bitfire.davdroid.syncadapter.ContactsSyncManager.prepareDirty(
    	at at.bitfire.davdroid.syncadapter.SyncManager.performSync(
    	at at.bitfire.davdroid.syncadapter.ContactsSyncAdapterService$ContactsSyncAdapter.onPerformSync(
    	at android.content.AbstractThreadedSyncAdapter$
    DAVdroid version: 1.6.3-ose (155) Sat Jul 08 11:01:09 CEST 2017
    Installed from: org.fdroid.fdroid
    JB Workaround installed: no
    android.permission.READ_CONTACTS permission: granted
    android.permission.WRITE_CONTACTS permission: granted
    android.permission.READ_CALENDAR permission: granted
    android.permission.WRITE_CALENDAR permission: granted
    org.dmfs.permission.READ_TASKS permission: granted
    org.dmfs.permission.WRITE_TASKS permission: granted
    System-wide synchronization: automatically
    Account: username@domain.invalid
      Address book sync. interval: 240 min
      Calendar     sync. interval: 240 min
      OpenTasks    sync. interval: 240 min
      WiFi only: false
      [CardDAV] Contact group method: GROUP_VCARDS
      [CalDAV] Time range (past days): 900
               Manage calendar colors: true
    Address book account: Contacts (username@domain.invalid ag)
      Main account: Account {name=username@domain.invalid,}
      URL: https://zimbra.domain.invalid/dav/username@domain.invalid/Contacts/
      Sync automatically: true
    	|  locale |
    	|  en_US |
    	|  setting | value |
    	|  _id | accountName | service | principal |
    	|  5 | username@domain.invalid | carddav | https://zimbra.domain.invalid/principals/users/username@domain.invalid/ |
    	|  6 | username@domain.invalid | caldav | https://zimbra.domain.invalid/principals/users/username@domain.invalid/ |
    	|  name | seq |
    	|  services | 6 |
    	|  collections | 17 |
    	|  homesets | 12 |
    	|  _id | serviceID | url |
    	|  11 | 6 | https://zimbra.domain.invalid/dav/username@domain.invalid/ |
    	|  12 | 5 | https://zimbra.domain.invalid/dav/username@domain.invalid/ |
    	|  _id | serviceID | url | readOnly | displayName | description | color | timezone | supportsVEVENT | supportsVTODO | sync |
    	|  13 | 6 | https://zimbra.domain.invalid/dav/username@domain.invalid/Calendar/ | 0 | Calendar | username's Calendar | -690174 | <null> | 1 | 0 | 1 |
    	|  14 | 6 | https://zimbra.domain.invalid/dav/username@domain.invalid/Tasks/ | 0 | Tasks | username's Tasks | -690174 | <null> | 0 | 1 | 1 |
    	|  15 | 6 | https://zimbra.domain.invalid/dav/username@domain.invalid/Another%20calendar/ | 1 | Another calendar | username's Another calendar | -16624940 | <null> | 1 | 0 | 1 |
    	|  16 | 5 | https://zimbra.domain.invalid/dav/username@domain.invalid/Contacts/ | 0 | Contacts | username's Contacts | <null> | <null> | <null> | <null> | 1 |
    	|  17 | 5 | https://zimbra.domain.invalid/dav/username@domain.invalid/Emailed%20Contacts/ | 0 | Emailed Contacts | username's Emailed Contacts | <null> | <null> | <null> | <null> | 0 |
    Android version: 4.2.2 (W20-HL.V0035)
    Device: FP1 FP1 (FP1)
    --- END DEBUG INFO ---

    I’ve changed my username to username and the hostname of my server to domain.invalid, but otherwise the debug log is untouched.

    I didn’t have any problems until now. I also didn’t delete contact pictures until now, so I’m not sure if this bug is introduced in a recent version of DAVdroid or if it has been present for some time already.

  • developer

    Thanks for the report. Again, a class which has close() but does not implement Closeable on old Android versions, which does not make it compatible with Kotlin’s use idiom.

    I can work around this in the next version, but please consider updating your Android version (for instance by installing a custom ROM, even Android 4.4 would be a big win). It’s so much work to test and support those old versions and it doesn’t make any sense at all, because many of those bugs are already fixed in newer Android versions.

  • Hi rfc2822,

    Thanks for your quick reply.

    I’ll see what I can do regarding upgrading my Android version. Bad news is that support for my phone has been dropped about a week ago, so I won’t have a(n official) upgrade path.
    There is an unofficial Kitkat build for my phone, which I might check out.

    I’d be very grateful if you could fix the issue I’ve encountered. As I said before, I never had any problems with DAVdroid before (except for some small issues that were always fixed 1 or 2 releases after I’ve encountered the bugs).

    Would you like me to create new bug reports if I encounter problems in the future or do you consider issues I might have WONTFIX because of my outdated Android version?
    I don’t mind reporting any future issues, but I don’t want to spam the forum with reports that won’t get fixed anyway. That’s a waste of both your time and mine.

  • developer

    @sputtene I have seen that fp1 is not very well supported and there are no custom ROMs for it (driver problems?) which is very sad (I have an fp2 myself; fp2 seems to be better supported and there are LinageOS builds for Android 7.1).

    The problem with the close() without Closeable is not a big problem, it’s just an inconvenience (because DAVdroid is now being rewritten to Kotlin, and Kotlin’s use requires a Closeable). So there are some places in the code where I have used Kotlin’s use and which now don’t work because older Android versions don’t implement Closeable for these classes yet, but newer Android versions do, so we don’t notice that when testing.

    At the moment, all versions from Android 4.1 are officially supported by DAVdroid, so this will be fixed (= use try/finally with close() again instead of Kotlin’s use). Please keep reporting such problems (thanks!). However, we might increase the required SDK level from time to time so that Android 4.2 or even Android 4.4 may be the minimum required Android version.

  • @rfc2822 On July 11th, Fairphone sent an email to all FP1 owners stating that they would (could) no longer support the FP1, both with hardware (spare parts) and with software updates (like the Android Kitkat build).
    I plan on using my FP1 for as long as it’s working and then get an FP2 or maybe even an FP3 if my current phone lasts that long 🙂
    Anyway, this means I’m stuck with Android 4.2.2, unless I install the alpha 4.4 build. I might do that, but I’m not sure yet.

    I’ll keep on posting bug reports when I encounter problems then, at least until you declare Android 4.2.2 not supported anymore.

    By the way, thanks for DAVdroid! I really like it!

  • developer

    Should be solved with vcard4android/f8bf656f and DAVdroid 1.6.4, please tell us whether it works (couldn’t really test because the 4.1 emulator doesn’t accept SD cards properly, so that the camera emulation does not work, so that I can’t take a photo from Contacts app, which would be required to test that).

  • Hi,

    Can you tell me how to test it? I get my DAVdroid updates from f-droid, but I guess you won’t release the update as an official version before I have been able to confirm the bug is fixed?

    If you could point me to instructions on how to create and/or install an .apk with the fix, I’ll happily test and report.

    If you are releasing the fix on f-droid, I’ll just wait for the update and report afterwards.

  • developer

    @sputtene I have sent the APK by email.

Similar topics

  • 3
  • 2
  • 11