问题
I want to use geotools(8.0-M3 currently, could be also 2.7.3) library in an Android app, using eclipse. (win7 prof, 4gb ram) But the build process crash, and i get following error
Unhandled event loop exception Java heap space
The java heap space problem should be solveable, but it seems there is more. (3gb should be enough, isn't it?)
My final target is to be able to request a postgres postgis db on geoserver by OGC "web feature service" and "web map service".
I already set the eclipse ini to
--launcher.XXMaxPermSize 128m --launcher.defaultAction openFile -vmargs -Xms40m -Xmx3700m
Geotools require more than android libs (in compare with jre6 (1.6.0_24)) provide.
-> So I copy the whole jars from jre6 folder plus jts-1.8.jar plus the geotools jars into a seperate (win) folder. (Maven(not in use in this case!) by itself load jts-1.1.3 lib, does it make any difference?) The whole jar folder has a size of nearly 80Mb.
-> Create a new folder in eclipse android project struture.
-> import the jar files from the win folder into eclipse
-> add the jars to the project build path (which should port java to dx) (After a long time (days) of trial thats the only way i know, to provide all neccessary classes to the app. At least eclipse doesn't mark anything missing).
After the compilation crased the eclipse console output:
Dx warning: Ignoring InnerClasses attribute for an anonymous inner class.....
for several classes. Probably because of the jre lib.
What other options to provide geotools the necessary java libs in my android project do i have? Or do you have any idea of the trials i mentioned below?
PS: Android books recommend to copy just the missing classes (and their dependencies Haha) out of the jar files..... (i will probably better write them new)
I already tried using the maven plugin. Which works well in a pure java project using geotools or as it take care of an android project as long i don't use geotools. If maven include an android project using geotools the libs are loaded by maven but then android say something like "R class modified manually"... (what i can't revert, or recreate)
Is there a way to copy the maven dependecy library (which should consist of what i need) out of the eclipse project. (I thought i could copy the jars out of the win repository folder, but that include also to much others jars).
Android provide a "Java Native Interface" which allows to use C++ or other libs. Would it be an option to surround the porblem of missing/crossing libs (I have no experience of JNI yet)?
The app code is pretty short, if it help you i can paste it.
回答1:
What other options to provide geotools the necessary java libs in my android project do i have?
If you need classes that are part of a standard Java distribution but are not in Android, you are out of luck, other than to rewrite geotools to avoid needing those classes.
If you need classes that are part of other third-party Java libraries, add those third-party Java libraries to your project.
From a brief examination of geotools, I suspect that it will need to be substantially rewritten to run on Android.
PS: Android books recommend to copy just the missing classes (and their dependencies Haha) out of the jar files
My books do not. Any author advising this needs to have their head examined.
来源:https://stackoverflow.com/questions/8256845/android-app-build-on-geotools-library-missing-native-java-libs