开发者

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

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.Trave开发者_JAVA技巧lPharm.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!!!


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.


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.


I found a workaround for Froyo (2.2), but the APK got from 4.x megs long to 10.x megs. Make it simple: rezip the apk file, with compression 0. I did this on Windows: 1.-Rename the apk file to zip, 2.-unzip it to some folder, 3.-zip it again with "store" option (I'm really using WinRAR, so "store" means no compression at all), 4.-then rename it back from zip to apk, 5.-and install it.


Just changing the .db extension to .png it will worked in 2.2 and above devices


You can split the file and put the split files in assets folder.
For e.g largfile.db to db1.db, db2.db, db3.db
And then write code to combine these files back to largefile.db on the device.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜