java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
You can disable asset compression for certain extensions like so:
android {
aaptOptions {
noCompress "pdf"
}
}
Source
People working with Tensorflow Lite file running into this issue,
Add the following lines to your Gradle file (android/app/build.gradle
) inside the android{}
block.
aaptOptions {
noCompress "tflite"
}
There is a limitations on opening compressed files in the assets folder. This is because uncompressed files can be directly memory mapped into the processes virtual address space, therefore avoiding needing the same amount of memory again for decompression.
Dealing with Asset Compression in Android Apps discusses some techniques in dealing with compressed files. You can trick aapt
into not compressing the file by using an extension that is not compressed (e.g. mp3
) or you can manually add them to the apk
without compression instead of getting aapt
to do the work.