Re: [android-developers] library byte code (in)compatibility if added as an external jar

2011-01-15 Thread Mark Murphy
On Sat, Jan 15, 2011 at 7:54 PM, Shawn Brown big.coffee.lo...@gmail.com wrote:
 To add a 3rd party .jar to Android I followed Android suggested
 practice(1) by adding the .jar as a Library [not as an Android Library
 under Eclipse (2)], but am
 being told this may induce byte code incompatibilities?

 Can I safely use a .jar compiled with a JDK in Android?

Possibly. It depends.

 I think I can but am told by a fellow developer:

  This is wrong. One missing method (even if it is one of many overloads
 of a single method name) that is present in the JDK but not in Android,
 and you've got byte code that is only compatible with the JDK, but not
 with Android.

That developer is correct. That is one of a few possible problems with
adding third party JARs to Android. That just means you may get errors
when you try using the JAR.

 Using an Android SDK is the only safe (and the easiest) way of getting
 byte code that runs under Android without any surprises. No way, of
 doing the same using only a JDK.

You can certainly set up an Ant project (and presumably an
Eclipse/NetBeans one) that builds against the Android SDK stub runtime
JAR rather than the Java SDK runtime JARs, and that will help identify
possible incompatibilities. However, if you are going to do that, you
might consider just putting the source code in your own project, and
skip the hassle of packaging the JAR. And, there is no particular harm
in just using the Java SDK compiled JAR, assuming your testing of your
application is thorough.

 If this is true, where can I file a bug against your documentation.

What bug?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] library byte code (in)compatibility if added as an external jar

2011-01-15 Thread Shawn Brown
 Can I safely use a .jar compiled with a JDK in Android?

 Possibly. It depends.


  This is wrong. One missing method (even if it is one of many overloads
 of a single method name) that is present in the JDK but not in Android,
 and you've got byte code that is only compatible with the JDK, but not
 with Android.

 That developer is correct. That is one of a few possible problems with
 adding third party JARs to Android. That just means you may get errors
 when you try using the JAR.



 If this is true, where can I file a bug against your documentation.

 What bug?

Are you joking?
http://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary

Android docs say add 3rd party libraries as a .jar.

Android docs do mention this at all - that incompatibilities may be
induced and that the jar will be inaccessable.
It really should.

Shawn

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] library byte code (in)compatibility if added as an external jar

2011-01-15 Thread Mark Murphy
On Sat, Jan 15, 2011 at 8:21 PM, Shawn Brown big.coffee.lo...@gmail.com wrote:
 What bug?

 Are you joking?

No.

 http://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary

 Android docs say add 3rd party libraries as a .jar.

Correct. I'd venture that at least one Android app in 10 does so. It's
fairly commonplace.

 Android docs do mention this at all - that incompatibilities may be
 induced and that the jar will be inaccessable.
 It really should.

You have a different definition of documentation bug than I do. By
your definition, every piece of documentation ever written has bugs,
since every piece of documentation ever written could always add more
material.

Moreover, you run into the same problems trying to use JARs between
different Java editions (e.g., JavaME vs. JavaSE vs. JavaEE), Java
versions (e.g., Java 7 vs. Java 6 vs. Java 5 vs. ...), and different
Java implementations (e.g., GCJ vs. OpenJDK). The issues are more
prevalent in Android, because it is by definition different than any
other Java-ish environment. However, this sort of stuff happens all
the time in Java development, and experienced Java developers should
not be fazed by it.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en