ankidroid / ankidroid/Anki-Android

Import fails with "stream did not contain valid UTF-8" on Android 16, even for a byte-identical round-trip of an already-working deck

Đang mở
#21,430 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Needs Author Reply Needs Triage
Ngôn ngữ chính
Kotlin
Star
11.8k
Fork
2.9k
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
171

Mô tả

### Checked for duplicates?

- [x] This issue is not a duplicate

### Does it also happen in the desktop version?

- [x] This bug does not occur in the latest version of Anki Desktop

### What are the steps to reproduce this bug?

1. Export a deck from AnkiDroid on this device (this file imports fine — control case).
2. On a separate machine, install `anki==25.9.2` via pip. It reports `buildhash: 3890e12c` — the exact same core commit as this device's bundled backend.
3. Using that pip package, import the file from step 1 with Collection.import_anki_package(), then immediately export it again with Collection.export_anki_package(), with no content changes (with_scheduling=True, with_deck_configs=True, with_media=True, legacy=False).
4. Transfer the resulting file back to the device and import it via Menu → Import (not "Open with" — ruling out share-intent/cache-copy timing issues).

Also tried with legacy=True on export (produces collection.anki21 instead of collection.anki21b) — same error. CSV import of equivalent content works fine on the same device, same session.

### Expected behaviour

Expected: import succeeds, since the file is a scheduling/content-preserving round-trip of a file that already imports successfully on this device, produced by the exact same core commit (3890e12c) as the device's bundled backend.

Actual: fails with the same error as any other freshly-generated .apkg:
500: Failed to read 'data/user/0/com.ichi2.anki/cache/.apkg': stream did not contain valid UTF-8

Since the backend commit is identical between the working and failing files, and content/schema-level checks all matched (zip entry list, `meta` version bytes, decompressed collection.anki21b SQLite schema/content), this looks specific to how AnkiDroid's Kotlin/JNI layer reads the file into the Rust core on this Android version/device rather than a core-library or file-content issue. Android 16 is a very recent release, so a scoped-storage/file-access change there seems like a plausible lead.

### Debug info

```text
AnkiDroid Version = 2.24.0 (ebcf8e0e34921628b9b8a496c66ffd4adbb3705f)
Backend Version = 0.1.64-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)
Android Version = 16 (SDK 36)
ProductFlavor = play
Device Info = samsung | samsung | gts10fepwifi | gts10fepwifixx | SM-X620 | s5e8855
WebView Info = [com.google.android.webview | 787118103]: Mozilla/5.0 (Linux; Android 16; SM-X620 Build/BP4A.251205.006; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/150.0.7871.181 Safari/537.36
ACRA UUID = 673d35c1-959b-4177-a8b1-effe863b711b
FSRS = 5.1.0 (Enabled: true)
Crash Reports Enabled = true
```

### (Optional) Anything else you want to share?

Happy to provide any of the generated test .apkg files or run further diagnostics if useful.

### Research

- [x] I have checked the [manual](https://docs.ankidroid.org/) and the [FAQ](https://github.com/ankidroid/Anki-Android/wiki/FAQ) and could not find a solution to my issue
- [ ] (Optional) I have confirmed the issue is not resolved in the latest alpha release ([instructions](https://docs.ankidroid.org/manual.html#betaTesting))

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.