Potential problem with the bundles on central - json

794 views
Skip to first unread message

Manfred Moser (simpligility)

unread,
Jun 29, 2010, 11:54:01 AM6/29/10
to Maven Android Developers
Hi!

Via a comment on my site i found that it looks like the 2.1 package
(at least) is missing the transitive dependency to org.json classes.
Could you check that out Robert?

Thanks

manfred

Robert Manning

unread,
Jun 29, 2010, 12:12:58 PM6/29/10
to maven-androi...@googlegroups.com
I'll look into it.

Rob

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

robert.m...@gmail.com

unread,
Jun 29, 2010, 7:37:09 PM6/29/10
to Maven Android Developers

What is it that depends on json ? When I grep the class files shipped
in android-7 platform jar I see:

find . -name *.class | xargs grep -i json
Binary file ./org/json/JSONTokener.class matches
Binary file ./org/json/JSONObject.class matches
Binary file ./org/json/JSONArray.class matches
Binary file ./org/json/JSONException.class matches
Binary file ./org/json/JSONStringer.class matches

So, nothing shipped in the android "super" jar depends on it - I'm
confused.

Certainly nothing in the android stub artifact in Central has a direct
dependency on org.json (or else it wouldn't compile)
Also, I ran dependency:tree on each of the maven projects I produced
for 2.1 and nothing has a transitive dependency on it either.

Perhaps it will show up as a dependency in the implementation artifact
(in stripping the implementation, perhaps they also pruned the
imports). There are already some new dependencies that are not in
central - here we again
(org.apache.harmony.luni.internal.util.TimezoneGetter ??)

Rob

On Jun 29, 11:54 am, "Manfred Moser (simpligility)"

Manfred Moser

unread,
Jun 29, 2010, 7:44:09 PM6/29/10
to maven-androi...@googlegroups.com
I believe Matthias Kaeppler is using the 2.1 artifact for his android
library droid-fu or so. In any case the SDK provides these classes for app
developer. We either embed them in the jar or add a transitive dependency
as replacement.

manfred

Jeff Campbell

unread,
Jul 8, 2010, 12:57:06 PM7/8/10
to Maven Android Developers
I'm also seeing this problem.... the only current work-around that I
have for this is to add the following dependency to my pom.xml:

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
<scope>provided</scope>
</dependency>

Jeff

On Jun 29, 9:54 am, "Manfred Moser (simpligility)"

Manfred Moser

unread,
Jul 8, 2010, 1:45:17 PM7/8/10
to maven-androi...@googlegroups.com
Thanks.. that is a good workaround.

Robert Manning

unread,
Jul 8, 2010, 8:47:18 PM7/8/10
to maven-androi...@googlegroups.com
You will need to be using JDK 1.6 for that dependency. I get the
following using 1.5 :

[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

/home/manningr/projects/android4maven/target-2.2/android-impl-android-2.2/src/main/java/com/android/quicksearchbox/google/GoogleSuggestionProvider.java:[26,-1]
cannot access org.json.JSONArray
bad class file:
/home/manningr/.m2/repository/org/json/json/20090211/json-20090211.jar(org/json/JSONArray.class)
class file has wrong version 50.0, should be 49.0


I read somewhere that recently Google SDK team removed the last
remaining dependencies that required 1.5 to build the SDK, so it may
no longer be an obstacle. But if you can't use 1.6, then the
following may work:

<groupId>org.json</groupId>
<artifactId>json</artifactId>

<version>20080701</version>

Rob

Manfred Moser

unread,
Jul 8, 2010, 9:33:57 PM7/8/10
to maven-androi...@googlegroups.com, Robert Manning
That is correct. JBQ confirmed on the android building list that 64 bit
Java 6 is now required...

Oh and btw. revision 2 of 2.2 was made available today.

manfred

-------- <<< 0 >>> ---------
Manfred Moser
Cell: ++1 (250) 514 0135
man...@simpligility.com
http://www.simpligility.com

On Thursday July 8 2010, Robert Manning wrote:
> You will need to be using JDK 1.6 for that dependency. I get the
> following using 1.5 :
>
> [ERROR] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------
> ------ [INFO] Compilation failure
>
> /home/manningr/projects/android4maven/target-2.2/android-impl-andro
> id-2.2/src/main/java/com/android/quicksearchbox/google/GoogleSugges
> tionProvider.java:[26,-1] cannot access org.json.JSONArray
> bad class file:
> /home/manningr/.m2/repository/org/json/json/20090211/json-20090211.

> jar(org/json/JSONArray.class) class file has wrong version 50.0,

matthias

unread,
Aug 26, 2010, 4:08:12 AM8/26/10
to Maven Android Developers
There's another problem:

the org.json JARs on Central come with a broken JSONStringer class.
That class is empty, it only contains a toString() method.

What I don't understand is this:
We have a transitive dependency on the 2008 JSON JAR from Central via
the Android 2.1 JAR from Central using the provided scope. However,
our code using JSONString compiles fine in Eclipse, which basically
means that Eclipse compiles against the android.jar from the ADT, not
the Maven JARs.

When we run the app on the emulator or device, however, the app breaks
on a MethodMissing due to said problems with the JSONStringer class,
which basically means that on a device, the app links against the
Maven JARs and NOT the JARs provided by the Android runtime!

Shouldn't it be exactly the other way around? Why are the Maven
dependencies deployed with the app and even override the framework
classes?


On Jul 9, 3:33 am, Manfred Moser <manf...@simpligility.com> wrote:
> That is correct. JBQ confirmed on the android building list that 64 bit
> Java 6 is now required...
>
> Oh and btw. revision 2 of 2.2 was made available today.
>
> manfred
>
> -------- <<< 0 >>> ---------
> Manfred Moser
> Cell: ++1 (250) 514 0135
> manf...@simpligility.comhttp://www.simpligility.com
>
> On Thursday July 8 2010, Robert Manning wrote:
>
> > You will need to be using JDK 1.6 for that dependency.  I get the
> > following using 1.5 :
>
> > [ERROR] BUILD FAILURE
> > [INFO]
> > ------------------------------------------------------------------
> > ------ [INFO] Compilation failure
>
> > /home/manningr/projects/android4maven/target-2.2/android-impl-andro
> > id-2.2/src/main/java/com/android/quicksearchbox/google/GoogleSugges
> > tionProvider.java:[26,-1] cannot access org.json.JSONArray
> > bad class file:
> > /home/manningr/.m2/repository/org/json/json/20090211/json-20090211.
> > jar(org/json/JSONArray.class) class file has wrong version 50.0,
> > should be 49.0
>
> > I read somewhere that recently Google SDK team removed the last
> > remaining dependencies that required 1.5 to build the SDK, so it
> > may no longer be an obstacle.  But if you can't use 1.6, then the
> > following may work:
>
> > <groupId>org.json</groupId>
> > <artifactId>json</artifactId>
> > <version>20080701</version>
>
> > Rob
>
> > On Thu, Jul 8, 2010 at 12:57 PM, Jeff Campbell <jeffdc...@gmail.com>

matthias

unread,
Aug 26, 2010, 4:57:12 AM8/26/10
to Maven Android Developers
I indeed could resolve this error by not relying on the Maven Central
Android JARs, but the normal one (installed via maven-android-sdk-
deployer).

I think this issue can only be fixed by submitting a new JSON JAR to
Maven Central, since the current one is obviously broken.

Robert Manning

unread,
Aug 27, 2010, 6:19:26 PM8/27/10
to maven-androi...@googlegroups.com
http://www.json.org/java/index.html has the latest version of the
source code. The JSONStringer there is from 2008-09-18. It matches
what is available in Maven Central - just a constructor and a
toString() method. My guess is that Android is relying on Google's
fork of this library. The source code for this class
(./dalvik/libcore/json/src/main/java/org/json/JSONStringer.java) has
the following nugget :

// Note: this class was written without inspecting the non-free
org.json sourcecode.

Along with a bunch of their own custom code. What a mess for Maven
developers to sort through! They should have changed the package of
the source as they were forking it. It's considered taboo to release
the same classes under different maven coordinates. It is also taboo
to release forked versions using the same maven coordinates as the
"official" version. Now, if we the re-package the forked artifacts
they will become useless for Android developers.
And this is just the tip of the iceberg...

Rob

Fabrizio Giudici

unread,
Aug 27, 2010, 6:32:59 PM8/27/10
to maven-androi...@googlegroups.com, Robert Manning

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/28/10 00:19 , Robert Manning wrote:
> http://www.json.org/java/index.html has the latest version of the
> source code. The JSONStringer there is from 2008-09-18. It
> matches what is available in Maven Central - just a constructor and
> a toString() method. My guess is that Android is relying on
> Google's fork of this library. The source code for this class
> (./dalvik/libcore/json/src/main/java/org/json/JSONStringer.java)
> has the following nugget :
>
> // Note: this class was written without inspecting the non-free
> org.json sourcecode.
>
> Along with a bunch of their own custom code. What a mess for Maven
> developers to sort through! They should have changed the package
> of the source as they were forking it. It's considered taboo to
> release the same classes under different maven coordinates. It is
> also taboo to release forked versions using the same maven
> coordinates as the "official" version. Now, if we the re-package
> the forked artifacts they will become useless for Android
> developers. And this is just the tip of the iceberg...

So glad I've just ignored Android JSON stuff and I'm relying on
org.json.me :-)

- --
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
Fabrizio...@tidalwave.it
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkx4PRsACgkQeDweFqgUGxfRXQCfTpC7X2h9qMjnU/yF1cfuceAm
+HYAn2MrxpoW1shKuYj6s1JULss0OU77
=a/P0
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages