The Problem
Upon launching on Android 16 (specifically crDroid), TIM version 4.0.98 reports the error “Unable to store file; please check the SD card status.” Consequently, the application fails to load images or cache files.
Root Cause
Android 16 contains a bug wherein the directory /storage/emulated/0/Android/data/<package_name>/ is not automatically created following the installation of an application. TIM’s NTKernel (at the C++ layer) constructs file paths directly for writing purposes, bypassing the standard Java API getExternalFilesDir(). As a result, the system is not triggered to automatically create the necessary directory, causing all file write operations to return EIO (error -5). ## Key Logs
W ContextImpl: Failed to ensure /storage/emulated/0/Android/data/com.tencent.tim/cache
E NTKernel: CreateTempDir Fail. error:-5 path=/storage/emulated/0/Android/data/com.tencent.tim/Tencent/Tim/chatpic/Temp
E NTKernel: CreateFileDir Fail. error:-5 path=/storage/emulated/0/Android/data/com.tencent.tim/Tencent/Tim/chatpic/chatraw/a29
E NTKernel: fail to create directory:/storage/emulated/0/Android/data/com.tencent.tim/Tencent/Tim/chatpic/Temp(-5)
Temporary Workaround
Obtain TIM’s UID:
su -c "stat -c %u /data/data/com.tencent.tim"
Manually create the directories and set the correct ownership (replace 10499 with the actual UID):
su -c "mkdir -p /storage/emulated/0/Android/data/com.tencent.tim/cache && \
mkdir -p /storage/emulated/0/Android/data/com.tencent.tim/files && \
chown -R 10499:10499 /storage/emulated/0/Android/data/com.tencent.tim && \
chmod -R 771 /storage/emulated/0/Android/data/com.tencent.tim"
Notes (Personal Observations)
- This issue stems from an upstream bug in Android 16; it is not specific to crDroid and can be reproduced on stock Pixel devices as well.
- Other apps that create directories using the Java API (
getExternalFilesDir()) are unaffected. - TIM has not been adapted for Android 16, and its testing scope appears to be largely limited to ROMs from domestic Chinese manufacturers.