Issue 361 in google-api-java-client: Unable to load JacksonFactory class in version 1.6.0-beta

1,209 views
Skip to first unread message

google-api-...@googlecode.com

unread,
Nov 27, 2011, 8:42:07 PM11/27/11
to google-api-jav...@googlegroups.com
Status: New
Owner: rmis...@google.com
Labels: Type-Defect Priority-Medium

New issue 361 by perez...@gmail.com: Unable to load JacksonFactory class in
version 1.6.0-beta
http://code.google.com/p/google-api-java-client/issues/detail?id=361

Version of google-api-java-client (e.g. 1.5.0-beta)?
1.6.0-Beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Java 6, Android 2.2


Describe the problem.
In the YouTube Sample code, when creating the final jsonFactory = new
JacksonFactory(), I get a runtime exception on the Android emulator saying
class not found, JacksonFactory. I included every possible library I could
within the dependencies including jackson-asl-core-1.9.1. Project built and
ran fine when running in regular Java environment, but I get class not
found when running on Android environment.

How would you expect it to be fixed?
Temporary work-around was to use google-api-java-client 1.5.1-beta and
the .jar's in the dependencies folder worked just fine, but they don't work
in 1.6.0-beta. I also tried using a previous version of
jackson-asl-core-1.6.7 with google java client 1.6.0-beta, no good. Maybe
there's something wrong with the set up in one of the libraries that is
causing this class to not get loaded.

google-api-...@googlecode.com

unread,
Nov 28, 2011, 10:03:46 AM11/28/11
to google-api-jav...@googlegroups.com
Updates:
Status: RequestedFeedback

Comment #1 on issue 361 by yan...@google.com: Unable to load JacksonFactory

JacksonFactory should be unchanged between 1.5 and 1.6. Unfortunately I
suspect it is a problem with your set up. I would need more information in
order to reproduce it, including your setup. For example, one possible bug
I've seen in the past is that old versions of the Maven Eclipse plugin
added the dependencies to the compile classpath but not the runtime
classpath.

Note that the YouTube sample is actually a command-line sample, not an
Android sample.

google-api-...@googlecode.com

unread,
Dec 3, 2011, 7:25:54 PM12/3/11
to google-api-jav...@googlegroups.com

Comment #2 on issue 361 by nta...@gmail.com: Unable to load JacksonFactory

This is exactly the same problem as I am having in my project. I am not
using Ant or Maven to build my Android project, just relying on Eclipse for
the time being.

The exception I was getting initially is as follows:
java.lang.NoClassDefFoundError:
com.google.api.client.json.jackson.JacksonFactory

This class is in google-http-client-1.6.0-beta.jar, which was added to
the "Referenced Libraries" section by Eclipse automatically when I added
google-api-client-1.6.0-beta.jar. I suspected that Eclipse treats it as a
compile-time dependency only (it even included a comment saying "(from
Class-Path of google-api-client-1.6.0-beta.jar)" next to the .jar file in
the Referenced Libraries section), so I added
google-http-client-1.6.0-beta.jar explicitly to the class path to make it a
runtime dependency. This resulted in another runtime exception:

java.lang.NoClassDefFoundError: org.codehaus.jackson.JsonFactory

This time I added jackson-core-asl-1.9.1.jar to the class path explicitly
(it was already there as a compile-time dependency), but then I got another
exception:

java.lang.NoClassDefFoundError: com.google.common.base.Preconditions

So I also added guava-r09.jar to the class path, but then I got the
dreaded "Conversion to Dalvik format failed with error 1", with the
following stack trace:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added:
Lcom/google/common/base/FinalizableReference;
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main.processClass(Main.java:486)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main.access$400(Main.java:67)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main.processOne(Main.java:418)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.dx.command.dexer.Main.run(Main.java:206)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
java.lang.reflect.Method.invoke(Method.java:597)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:179)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:729)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:602)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.resources.Project.build(Project.java:124)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.ide.eclipse.adt.internal.project.ProjectHelper.build(ProjectHelper.java:869)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:146)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:928)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1132)
[2011-12-04 01:20:27 - Discovr Music for Android] Dx at
org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Apparently, it is trying to add guava-r09.jar *twice* to the .dex file. At
this point I'm kinda stuck. Any ideas?

google-api-...@googlecode.com

unread,
Dec 4, 2011, 3:50:20 AM12/4/11
to google-api-jav...@googlegroups.com

Comment #3 on issue 361 by nta...@gmail.com: Unable to load JacksonFactory

java.lang.NoClassDefFoundError: org.codehaus.jackson.JsonFactory

java.lang.NoClassDefFoundError: com.google.common.base.Preconditions

[

google-api-...@googlecode.com

unread,
Dec 16, 2011, 8:24:00 AM12/16/11
to google-api-jav...@googlegroups.com

Comment #4 on issue 361 by freeman...@gmail.com: Unable to load

Same problem here. All jars have been added to my lib folder (app engine
project) and have been included as referenced libraries. Looking in the
Jar for Jackson, you can see the jSonFactory inside, but for some reason
there is a bad reference it seems inside the jar.

google-api-...@googlecode.com

unread,
Dec 20, 2011, 12:08:43 PM12/20/11
to google-api-jav...@googlegroups.com

Comment #5 on issue 361 by antoniov...@gmail.com: Unable to load

Can compile build but when testing Android VM returns:

Could not find class 'org.codehaus.jackson.JsonFactory', referenced from
method com.google.api.client.json.jackson.JacksonFactory.<init>
VFY: unable to resolve new-instance 1782
(Lorg/codehaus/jackson/JsonFactory;) in
Lcom/google/api/client/json/jackson/JacksonFactory;
VFY: rejecting opcode 0x22 at 0x0003
VFY: rejected Lcom/google/api/client/json/jackson/JacksonFactory;.<init>
()V
Verifier rejected class Lcom/google/api/client/json/jackson/JacksonFactory;
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001db80)

google-api-...@googlecode.com

unread,
Dec 21, 2011, 5:42:47 PM12/21/11
to google-api-jav...@googlegroups.com

Comment #6 on issue 361 by tganesh2...@gmail.com: Unable to load

I am getting the same error as mentioned in comment(3).

google-api-...@googlecode.com

unread,
Dec 21, 2011, 5:52:53 PM12/21/11
to google-api-jav...@googlegroups.com

Comment #7 on issue 361 by nta...@gmail.com: Unable to load JacksonFactory

#6: if you are also getting the "Conversion to Dalvik format failed with
error 1" message, I managed to resolve that. Actually, the stack trace was
right, it was really trying to add
com.google.common.base.FinalizableReference twice, but not because of
guava-r09.jar. It turned out that my project also had Droid-Fu as a
dependency, and the JAR file of Droid-Fu contains Guava already, so one
copy of Guava came from google-http-client as a transitive dependency,
while the other copy of Guava was shipped with Droid-Fu. I resolved things
by re-packaging Droid-Fu and excluding Guava from it.

google-api-...@googlecode.com

unread,
Jul 6, 2012, 4:29:25 PM7/6/12
to google-api-jav...@googlegroups.com

Comment #8 on issue 361 by annieyan...@gmail.com: Unable to load
Has anyone manage to solve this problem? I'm having the exact same problem
with this "Could not find class 'org.codehaus.jackson.JsonFactory'" issue.
It's very frustrating as I'm completely stuck. Any help will be appreciated.

google-api-...@googlecode.com

unread,
Oct 3, 2012, 9:19:57 AM10/3/12
to google-api-jav...@googlegroups.com

Comment #9 on issue 361 by kel...@upande.com: Unable to load JacksonFactory
I'm also having the same issue. I'm trying to run the Google latitude
android example found here-->
http://blog.doityourselfandroid.com/2011/08/06/oauth-2-0-flow-android/

Explicitly adding the google-http-client-1.5.0-beta.jar doesn't help.
Anyone with the solution?

google-api-...@googlecode.com

unread,
Feb 7, 2013, 10:58:55 PM2/7/13
to google-api-jav...@googlegroups.com

Comment #10 on issue 361 by piusve...@gmail.com: Unable to load
Same issue here for me. I'm using Eclipse and am getting the error this
import cannot be resolved. Everything else appears to be fine.

import com.google.api.client.json.jackson.JacksonFactory;

google-api-...@googlecode.com

unread,
Mar 11, 2013, 3:06:58 AM3/11/13
to google-api-jav...@googlegroups.com

Comment #11 on issue 361 by ARANPA...@gmail.com: Unable to load
Solution is here:

Just add google-http-client-jackson-1.13.1-beta.jar file in libs folder of
your project.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

google-api-...@googlecode.com

unread,
Apr 20, 2013, 4:21:16 PM4/20/13
to google-api-jav...@googlegroups.com

Comment #12 on issue 361 by erikswed...@gmail.com: Unable to load
no that did not work here, 1.13.1-beta.jar. anyone having the right
combinations of jar's will make it work

google-api-...@googlecode.com

unread,
May 8, 2013, 1:36:12 AM5/8/13
to google-api-jav...@googlegroups.com

Comment #13 on issue 361 by the.anti.9: Unable to load JacksonFactory class
Adding the jackson-core-2.1.3.jar solved this issue for me.

google-api-...@googlecode.com

unread,
May 15, 2013, 3:22:06 PM5/15/13
to google-api-jav...@googlegroups.com

Comment #14 on issue 361 by ishas...@gmail.com: Unable to load
i have same prob .. pls guide me

google-api-...@googlecode.com

unread,
Jun 12, 2013, 11:58:12 AM6/12/13
to google-api-jav...@googlegroups.com

Comment #15 on issue 361 by youdhvee...@mediaagility.com: Unable to load
I was facing same issues,

I have removed jackson-core-asl-1.9.11.jar from my build path and added
jackson-core-2.1.3.jar and now it is working fine for me.

google-api-...@googlecode.com

unread,
Aug 17, 2013, 8:23:00 AM8/17/13
to google-api-jav...@googlegroups.com

Comment #16 on issue 361 by vipul.gr...@gmail.com: Unable to load
Having same issue. Working fine with Jackson v1 lib but whene I try to use
Jackson v2 lib it shows java.lang.NoClassDefFoundError:
com.google.api.client.json.jackson.JacksonFactory

google-api-...@googlecode.com

unread,
Aug 20, 2013, 4:26:47 AM8/20/13
to google-api-jav...@googlegroups.com

Comment #17 on issue 361 by amit.la...@mettl.com: Unable to load
Having Same issue
Could not find

google-api-...@googlecode.com

unread,
Aug 27, 2013, 8:39:49 AM8/27/13
to google-api-jav...@googlegroups.com

Comment #18 on issue 361 by lxrmarke...@gmail.com: Unable to load
java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory

Attachments:
exception.txt 3.8 KB

google-api-...@googlecode.com

unread,
Sep 14, 2013, 12:52:33 AM9/14/13
to google-api-jav...@googlegroups.com

Comment #19 on issue 361 by bennatpj...@gmail.com: Unable to load
Just setting up for Google drive sample project got stuck with the below

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
JacksonFactory cannot be resolved to a type

at DriveCommandLine.main(DriveCommandLine.java:28)

google-api-...@googlecode.com

unread,
Sep 23, 2013, 7:58:32 PM9/23/13
to google-api-jav...@googlegroups.com

Comment #20 on issue 361 by vegetoth...@gmail.com: Unable to load
I just fixed this by changing the following lines:

Original: import com.google.api.client.json.jackson.JacksonFactory;
Modified: import com.google.api.client.json.jackson2.JacksonFactory;

google-api-...@googlecode.com

unread,
Nov 13, 2013, 4:41:22 AM11/13/13
to google-api-jav...@googlegroups.com

Comment #21 on issue 361 by shadmazu...@gmail.com: Unable to load
On my case, solve the issue as following:
# download the "jackson-core-2.3.0-rc1.jar"
# add the jar as a library.
# Then restart Android studio.

google-api-...@googlecode.com

unread,
Jan 29, 2014, 3:13:39 AM1/29/14
to google-api-jav...@googlegroups.com

Comment #22 on issue 361 by daku...@uci.edu: Unable to load JacksonFactory
Tried #21 doesn't work.

google-api-...@googlecode.com

unread,
Apr 24, 2014, 5:53:25 PM4/24/14
to google-api-jav...@googlegroups.com

Comment #23 on issue 361 by j.becerr...@gmail.com: Unable to load
Solution 20 worked for me

google-api-...@googlecode.com

unread,
Aug 1, 2014, 2:02:00 PM8/1/14
to google-api-jav...@googlegroups.com

Comment #24 on issue 361 by chinthak...@gmail.com: Unable to load
java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory

changed

Original: import com.google.api.client.json.jackson.JacksonFactory;
Modified: import com.google.api.client.json.jackson2.JacksonFactory;

but no change same result.

google-api-...@googlecode.com

unread,
Aug 4, 2014, 10:08:39 AM8/4/14
to google-api-jav...@googlegroups.com

Comment #25 on issue 361 by amaankha...@gmail.com: Unable to load
using google-http-client-jackson-1.19.1-beta.jar

Trick works for me :D

Original: import com.google.api.client.json.jackson.JacksonFactory;
Modified: import com.google.api.client.json.jackson2.JacksonFactory;

google-api-...@googlecode.com

unread,
Oct 27, 2014, 3:30:19 AM10/27/14
to google-api-jav...@googlegroups.com

Comment #26 on issue 361 by abdulbas...@gmail.com: Unable to load
JacksonFactory class in version 1.6.0-beta
https://code.google.com/p/google-api-java-client/issues/detail?id=361

It worked for me guys. Just add all the depencies libraries in your project
lib folder and after that just add all the libraries from project to build
path. Means select all the libraries, right click -> Build path and add to
build path.

google-api-...@googlecode.com

unread,
Nov 6, 2014, 6:44:37 AM11/6/14
to google-api-jav...@googlegroups.com

Comment #27 on issue 361 by hanoha...@gmail.com: Unable to load
I solved it as adding jackson2 extension lib.

compile ('com.google.http-client:google-http-client:1.18.0-rc') {
exclude group: 'xpp3'
exclude group: 'org.apache.httpcomponents'
exclude group: 'junit'
exclude group: 'com.google.android'
}
compile 'com.google.http-client:google-http-client-jackson2:1.18.0-rc'

google-api-...@googlecode.com

unread,
Apr 9, 2015, 2:53:21 AM4/9/15
to google-api-jav...@googlegroups.com

Comment #28 on issue 361 by gurupras...@gmail.com: Unable to load
I got the solution . It worked for me.
When you add the jar file to build path and still not resolving this issue
simply restart your eclipse or android studio.
Reply all
Reply to author
Forward
0 new messages