Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get this error: Data exceeds UNCOMPRESS_DATA_MAX on android 2.2 but not on 2.3

Tags:

android

I am getting an error only on the version android 2.2 but not on 2.3.

The error :

 04-26 13:41:34.862: ERROR/Database(3701):  sqlite3_open_v2("/data/data/com.TravelPharm/databases/medicaments.sqlite", &handle, 1, NULL) failed
 04-26 13:41:34.942: DEBUG/dalvikvm(417): GC_EXPLICIT freed 82 objects / 4000 bytes in 1617ms
 04-26 13:41:35.062: DEBUG/asset(3701): Data exceeds UNCOMPRESS_DATA_MAX (17304576 vs 1048576)
 04-26 13:41:35.062: DEBUG/AndroidRuntime(3701): Shutting down VM
 04-26 13:41:35.072: WARN/dalvikvm(3701): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701): FATAL EXCEPTION: main
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701): java.lang.Error: Error copying database
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at com.TravelPharm.DBHelper.createDataBase(DBHelper.java:395)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at com.TravelPharm.TravelPharm.SumofDetails(TravelPharm.java:290)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at com.TravelPharm.TravelPharm.onCreate(TravelPharm.java:64)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.os.Handler.dispatchMessage(Handler.java:99)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.os.Looper.loop(Looper.java:123)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at android.app.ActivityThread.main(ActivityThread.java:4627)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at java.lang.reflect.Method.invokeNative(Native Method)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at java.lang.reflect.Method.invoke(Method.java:521)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
 04-26 13:41:35.103: ERROR/AndroidRuntime(3701):     at dalvik.system.NativeStart.main(Native Method)

i understand that is because my database is too big "UNCOMPRESS_DATA_MAX" so how can i solve the problem??

I will appreciate any help ,

Thank you!!!

like image 743
lido Avatar asked Apr 26 '11 10:04

lido


2 Answers

I too have a similar problem and after much searching, I found this page to answer my question.

http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/

In summary, Android compresses any asset file except the ones that are list on the page, since they are already compressed. This compressing is generally a good thing, but it comes back to haunt programmers when a file is too big. The two options that the author suggests are to 1)rename the database file to be one the doesn't get compressed (such as .jpg) or 2) turn off compression for the database's file extension (see the blog post on how to do that). Number 2 can be difficult though if you are using Eclipse so the author recommends using the first option.

This whole problem was corrected in Android 2.3.3 which is why you don't have the error appear :)

EDIT: This site explains it really simply: https://web.archive.org/web/20120423232710/http://www.nutprof.com/2010/12/data-exceeds-uncompressdatamax.html

EDIT 2: Looking back on this answer, I realize that depending on the size of your file, perhaps you could consider downloading the file from a web server and then copying it to wherever you need it to go. In my case, I was copying a SQLLite DB to the app private storage, but since the APK is signed, I couldn't get rid of the old database from my assests. So now instead of all that funky naming stuff, I just went and had it download it from the internet on the first run and put it in the private space. That way the application doesn't double its size on first run.

like image 58
Bob Avatar answered Nov 04 '22 08:11

Bob


I did what Bob has mentioned above. It worked great for me. I was unable to run the app on versions older than 2.3.3 but when I renamed my .html file (which was 4MB due to Web SQL commands) to .jet (or for that matter any already-compressed extension as mentioned in enter link description here), it worked fine on 2.1 update1 and 2.2 also.

The problem was Android versions older to 2.3.3 were trying to compress all files more than 1MB in size in the /assets/ folder. So, I renamed it to already-compressed extension so that the Android does not try to compress it again. Though I am not aware of Android programming, I think that is what is happening after reading the above and few other links online.

like image 2
ilight Avatar answered Nov 04 '22 08:11

ilight