CHJani / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Unable to load JacksonFactory class in version 1.6.0-beta #361

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by perez...@gmail.com on 28 Nov 2011 at 1:41

GoogleCodeExporter commented 9 years ago
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.

Original comment by yan...@google.com on 28 Nov 2011 at 3:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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
[
Apparently, it is trying to add guava-r09.jar *twice* to the .dex file. At this 
point I'm kinda stuck. Any ideas?

Original comment by nta...@gmail.com on 4 Dec 2011 at 8:49

GoogleCodeExporter commented 9 years ago
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.

Original comment by freeman...@gmail.com on 16 Dec 2011 at 1:22

GoogleCodeExporter commented 9 years ago
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)

Original comment by antoniov...@gmail.com on 20 Dec 2011 at 5:08

GoogleCodeExporter commented 9 years ago
I am getting the same error as mentioned in comment(3).

Original comment by tganesh2...@gmail.com on 21 Dec 2011 at 10:41

GoogleCodeExporter commented 9 years ago
#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.

Original comment by nta...@gmail.com on 21 Dec 2011 at 10:51

GoogleCodeExporter commented 9 years ago
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.

Original comment by annieyan...@gmail.com on 6 Jul 2012 at 8:29

GoogleCodeExporter commented 9 years ago
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?

Original comment by kel...@upande.com on 3 Oct 2012 at 1:19

GoogleCodeExporter commented 9 years ago
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;

Original comment by piusve...@gmail.com on 8 Feb 2013 at 3:58

GoogleCodeExporter commented 9 years ago
Solution is here:

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

Original comment by ARANPA...@gmail.com on 11 Mar 2013 at 7:06

GoogleCodeExporter commented 9 years ago
no that did not work here, 1.13.1-beta.jar. anyone having the right 
combinations of jar's will make it work 

Original comment by erikswed...@gmail.com on 20 Apr 2013 at 8:21

GoogleCodeExporter commented 9 years ago
Adding the jackson-core-2.1.3.jar solved this issue for me.

Original comment by the.anti.9 on 8 May 2013 at 5:35

GoogleCodeExporter commented 9 years ago
i have same prob .. pls guide me

Original comment by ishas...@gmail.com on 15 May 2013 at 7:21

GoogleCodeExporter commented 9 years ago
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.

Original comment by youdhvee...@mediaagility.com on 12 Jun 2013 at 3:57

GoogleCodeExporter commented 9 years ago
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

Original comment by vipul.gr...@gmail.com on 17 Aug 2013 at 12:22

GoogleCodeExporter commented 9 years ago
Having Same issue
Could not find
com.google.api.client.json.jackson.JacksonFactory

Original comment by amit.la...@mettl.com on 20 Aug 2013 at 8:26

GoogleCodeExporter commented 9 years ago
java.lang.ClassNotFoundException: com.google.api.client.json.JsonFactory

Original comment by lxrmarke...@gmail.com on 27 Aug 2013 at 12:39

Attachments:

GoogleCodeExporter commented 9 years ago
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)

Original comment by bennatpj...@gmail.com on 14 Sep 2013 at 4:52

GoogleCodeExporter commented 9 years ago
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;

Original comment by vegetoth...@gmail.com on 23 Sep 2013 at 11:58

GoogleCodeExporter commented 9 years ago
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.

Original comment by shadmazu...@gmail.com on 13 Nov 2013 at 9:41

GoogleCodeExporter commented 9 years ago
Tried #21 doesn't work.

Original comment by daku...@uci.edu on 29 Jan 2014 at 8:13

GoogleCodeExporter commented 9 years ago
Solution 20 worked for me

Original comment by j.becerr...@gmail.com on 24 Apr 2014 at 9:53

GoogleCodeExporter commented 9 years ago
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.

Original comment by chinthak...@gmail.com on 1 Aug 2014 at 6:01

GoogleCodeExporter commented 9 years ago
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;

Original comment by amaankha...@gmail.com on 4 Aug 2014 at 2:08

GoogleCodeExporter commented 9 years ago
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.

Original comment by abdulbas...@gmail.com on 27 Oct 2014 at 7:30

GoogleCodeExporter commented 9 years ago
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'

Original comment by hanoha...@gmail.com on 6 Nov 2014 at 11:44