views:

152

answers:

2

i'm trying to include a maven java project into my android project. the maven project is the greader-unofficial project which allows developers access to google reader accounts, and handles all of the http transactions and URI/URL building, making grabbing feeds and items from google reader transparent to the developer. the project is available here:

http://code.google.com/p/greader-unofficial/

the code is originally written for the standard jdk and uses classes from java.net that are not a part of the standard Android SDK. i actually tried to manually resolve all dependencies and ran into a problem when i got as far as including com.sun.syndication pieces required by the class be.lechtitseb.google.reader.api.util.AtomUtil.java... some of the classes in java.net that are in the standard jdk (i'm using 1.6) are not in the Android SDK. in addition, resolving all of these dependencies manually is just ridiculous when i'm compiling a maven project that should be pretty simple.

however, i can use maven to compile the sources with no issue. how can i include this maven project, which is dependent on the complete jdk, into my android project in such a way that it will compile so that i can access the GoogleReader class from my android project? and for the record, i don't have the expertise to rewrite this entire api to work with the standard Android SDK.

A: 

If the third party library requires standard JRE classes to compile it likely requires them to run as well. Try removing the third party methods/classes from your build that access the unavailable JRE classes. If your app still works with a stripped down library then deliver that (assuming the license is compatible with the change.) Likely, your only other option for that third party library is to replace the offending JRE calls with workarounds.

Chris Nava
A: 

The issue isn't building / compiling the code, right? It compiles just fine, as you say. It uses classes, directly or indirectly, that are not available in Android. (And, I do stress that even if it compiles, it doesn't mean it will run on Android, as it may need classes at runtime that aren't in Android.) So the issue is getting these classes into your .apk.

You can have the Android build inject copies of third-party libraries by adding them to external-libs. However I don't know that it works to just put the JDK's rt.jar file there (which has all java.net classes and everything else too). Your app will have second copies of standard Java libraries classes that will almost surely not be compatible in some way.

I strongly suspect it won't work, or if it happens to, will be fragile.

Is modifying the library so hard? If there are just a few java.net classes that aren't available, perhaps in a separate question you can solicit ideas about ways to work around not having them. Because actually in my experience Android has all the java.net classes so I'd be curious what's missing.

Sean Owen
i basically had to redo all the work to find exactly which dependencies were giving me issues. the greader api uses jaxen (org.jaxen.*) which depends on dom4j (org.dom4j.*) which depends on some classes in java.beans that aren't in the Android SDK, so the offending packages are jaxen and dom4j for depending on pieces of the JDK that aren't available in Android.either way, i can probably work around with it. i'll keep tooling around. thanks for the advice.
moonlightcheese