Solution to the "unable to get buffer of resource asset file" Problem

Source: Internet
Author: User

Problems 
When building you might run into the unable to get buffer of resource asset file error. the root cause of this is that the new Android resource file resources. ARSC is larger than the aapt tool allows. you can exchange. ARSC file inside android. jar with an older version or patch the aapt tool by editing frameworks/base/include/utils/asset. h.

Change both lines uncompress_data_max = 1*1024*1024 to something bigger. as the new resources file currently has a size of 2.3 MB you should change the lines (both lines mind You) to at least 3*1024*1024.

 

When using the SDK built by the default option under Linux for development, the following problems occur:

... Unable to get buffer of resource asset file

The solution is to set the product as SDK when building the SDK. There are two methods::

1. Use lunch to change the configuration:

Cd ~ /Android/src
. Build/envsetup. Sh
Lunch SDK-Eng
Make SDK

After configuration, the result is:

========================================================== ====
Platform_version_codename = REL
Platform_versions = 1.6
Target_product = SDK
Target_build_variant = ENG
Target_simulator = false
Target_build_type = release
Target_arch = arm
Host_arch = x86
Host_ OS = Linux
Host_build_type = release
Build_id = donut
========================================================== ====

2. directly use the make parameter:

Make product-SDK

 


Asset Limits the file size to 1 MB. 

When using the Res/raw or asset that comes with Android, you need to go through asset manager. This will produce a serious problem and there will be no problems during Android simulator testing, however, when it is placed on the host G1, multiple problems will occur. After checking that the value of uncompress_data_max is 1048576 bytes, dividing by 1024 is not hard to find that it is 1 MB. That is to say, the size of the Android mobile phone cannot exceed 1 MB when processing resource files. Because the standard G1 does not have the root permission, the folder under data/package name cannot be accessed. The size of the files stored in raw or asset cannot exceed 1048576 bytes, otherwise, the information of the obtained debug type is displayed in logcat. The tag is asset (PID): Data exceeds uncompress_data_max (2580997 vs 1048576), and a system error is generated. err, Java. io. ioexception.

Currently, the solution is to put the file into the sdcard, but this solution is not good except for the microSD reading Io efficiency and power consumption, and there may be problems when the SD card is removed, solution: if the data volume is large, SQLite is a solution, and openfileoutput reading is also a good choice. It seems that the Android operating system has the strictest security control, but I made a big mistake.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.