Porting java server to Android
Asked Answered
C

1

6

I'm working on developing a medical records system using OpenMRS as a backend for Android. OpenMRS is dependent on some seriously heavyweight libraries, including Hibernate and Spring.

"Dexing" the entire OpenMRS application generates a file that's too big even for the Android classes.dex file format (this size limit is already well-documented). To get around this, I'm currently working at creating multiple dex files from the dependencies and loading them during runtime using Android's dex classloader.

Because of the way the mobile version of the server will be used in practice, the actual processing demands will be very low despite the huge dependencies. I'm not trying to run an enterprise server on my phone here.

Before I spend weeks more of my time trying to engineer this, I just wanted to ask the developer community: is this strategy just a pipe dream? If I load up all these libraries, will the entire binary get loaded into RAM and just break the system? Is there a good way to optimize such an application? Is there some obvious problem or solution I'm missing here?

Carbazole answered 6/9, 2011 at 0:50 Comment(4)
At first glance, I'd say the dream of having Hibernate and Spring running on Android is unrealistic. The simple problem of having enough RAM for all these dependencies stops you dead in your tracks.Lablab
You've seen android-developers.blogspot.com/2011/07/… ? The hard part here seems to be that the various dex files can't just call between each other without additional code or preprocessing. (Assuming there's enough memory to do what you need.)Floccus
This definitely cries out for "client/server". One significant issue with this app will be to insure privacy (HPIAA regulations etc)Malleable
I had not seen the android developer post, that was extremely helpful! RAM seems to be the restriction on everybody's mind... does loading a class actually load the entire file into the RAM? As I understand it, desktop VMs only load references and refer to storage for the code. I can reduce the class library requirements to about 50MB I think, would I be able to run this on a tablet with 256MB of RAM?Carbazole
H
1

The short answer is: Don't.

The long answer is that most devices still only allocate a relatively small amount (between 40-128 megs of RAM) of memory to each heap. You really REALLY need to think about architecting the app so the bulk of the logic and thus the libraries and heavyweight code still reside on a server and the mobile app is just reading lightweight data (JSON?) from the server to display. Devices should really only utilize native items such as location data and provide an interface to the user that is consistent with the rest of the Android universe. Beyond that, you should be looking for ways to keep as much logic out of the native app as possible. If for no other reason than to keep it more secure. Reverse engineering Android applications is trivial and the more you keep on the server side, the more secure you will be.

Hellraiser answered 12/9, 2011 at 20:53 Comment(1)
Thanks Matt, I came to a similar conclusion after following up the comments. It looks like I'm going to have to do more recoding of the original source than I had thought. Having actually recorded the RAM it takes on my own computer, I realized that anything less than 1GB wouldn't work! But unfortunately the goal is to eventually have that whole server running on the tablet, since we're sending it to impoverished areas that don't have internet access. I guess this will need some REAL engineering. Sigh.Carbazole

© 2022 - 2024 — McMap. All rights reserved.