2

I was trying to serialize a TreeMap in my Android app so I can save it to a SharedPreferences, as suggested in this StackOverflow Q&A. It's for an ArrayList, but I took my chances anyway. The point is to use the ObjectSerializer class in the Apache Pig project to serialize the TreeMap into a String and save it in that data type in the shared prefs.

As soon as I imported the .jar without Hadoop, however, I began getting a lot of errors. When I run my app in the emulator (I use Eclipse), the status bar at the bottom of my IDE never goes past the message "Launching [app name] 100%..." Then, after a long while, this appears:

enter image description here

If I wait a little longer, more dialog boxes pop up on top of each other:

enter image description here

My questions are:

  1. What's going on and why is this happening? Might this be a bug with Apache Pig?
  2. Is there an alternative library which I can use to serialize my TreeMap? Right now, my workaround is to serialize it myself, as described in this tutorial, and save it in a file in the devices' internal memory separate from the shared prefs.
Community
  • 1
  • 1
Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132

2 Answers2

1

Can you try opening your eclipse.ini file and change the following parameters:

--launcher.XXMaxPermSize 512m

-XX:MaxPermSize=256m

-Xms512m

-Xmx1024m

Saurabh Verma
  • 6,328
  • 12
  • 52
  • 84
1

The solution is to simply not use Apache Pig in an Android app--it's a really bad move. Apache Pig is optimized for big data projects and requires huge physical resources to run. If you need just that one class to serialize your objects, it's not worth importing it.

I simply removed Pig from the app's referenced libraries and the app launched properly again in Eclipse.

Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132