android读取assets大于1M文件的解决方法
2012-08-05 15:02
549 查看
stackoverflow的原话:
The limitation is on compressed assets. If the asset is uncompressed, the system can memory-map the file data and use the Linux virtual memory paging system to pull in or discard 4K chunks as appropriate. (The "zipalign" tool ensures that uncompressed assets
are word-aligned in the file, which means they'll also be aligned in memory when directly mapped.)
If the asset is compressed, the system has to uncompress the entire thing to memory. If you have a 20MB asset, that means 20MB of physical memory is tied up by your application.
Ideally the system would employ some sort of windowed compression, so that only parts need to be present, but that requires some fanciness in the asset API and a compression scheme that works well with random access. Right now APK == Zip with "deflate" compression,
so that's not practical.
You can keep your assets uncompressed by giving them a suffix of a file type that doesn't get compressed (e.g. ".png" or ".mp3"). You may also be able to add them manually during the build process with "zip -0" instead of having them bundled up by aapt. This
will likely increase the size of your APK
总之:修改后缀名就OK了,修改为png或mp3格式。
The limitation is on compressed assets. If the asset is uncompressed, the system can memory-map the file data and use the Linux virtual memory paging system to pull in or discard 4K chunks as appropriate. (The "zipalign" tool ensures that uncompressed assets
are word-aligned in the file, which means they'll also be aligned in memory when directly mapped.)
If the asset is compressed, the system has to uncompress the entire thing to memory. If you have a 20MB asset, that means 20MB of physical memory is tied up by your application.
Ideally the system would employ some sort of windowed compression, so that only parts need to be present, but that requires some fanciness in the asset API and a compression scheme that works well with random access. Right now APK == Zip with "deflate" compression,
so that's not practical.
You can keep your assets uncompressed by giving them a suffix of a file type that doesn't get compressed (e.g. ".png" or ".mp3"). You may also be able to add them manually during the build process with "zip -0" instead of having them bundled up by aapt. This
will likely increase the size of your APK
总之:修改后缀名就OK了,修改为png或mp3格式。
相关文章推荐
- arcgis for android 读取shp文件中文乱码解决方法
- Android读取xxx.properties配置文件中文出现乱码解决方法
- Android开发-asset中文件超过1M的解决方法
- Android开发实现读取assets目录下db文件的方法示例
- android中使用sqlite、复制assets下的数据库到SD卡、支持大于1M的文件
- Android编程读取Assets所有文件(遍历每一个文件夹)并存入sdcard的方法
- android解决读取assets文件夹下的json或txt文件乱码问题
- 读取xml文件出现错误的一个解决方法(android)
- Android开发-asset中文件超过1M的解决方法
- android导入外部已存在的数据库大于1M的数据库文件方法
- android中使用sqlite、复制assets下的数据库到SD卡、支持大于1M的文件
- Android开发-asset中文件超过1M的解决方法
- android中使用sqlite、复制assets下的数据库到SD卡、支持大于1M的文件
- Android读取中文文件乱码解决方法
- android导入外部已存在的数据库大于1M的数据库文件方法
- android从assets读取文件的方法
- Android读取本地json文件的方法(解决显示乱码问题)
- 读取android assets 文件 方法
- android导入外部已存在的数据库大于1M的数据库文件方法
- unity发布失败,文件读取出错的解决方法(The file 'resources.assets' is corrupted)