I'm using the Java Google APIs for an Android application. I followed the usage pattern described here for Authenication and API use: http://goo.gl/rPZ9Z
The problem I'm having is that the call to GoogleTransport.create() throws a NoClassDefFoundException. I looked at the log and the HttpHeaders class is not linking properly. I attached the Google API JAR file using the normal method in eclipse and all other classes I'm using are working correctly. Problem is that this one class in particular is not linked correctly. Here are some logs of the app running but not calling the class:
01-27 14:04:34.390: WARN/dalvikvm(422): Link of class 'Lcom/google/api/client/http/HttpHeaders;' failed
01-27 14:04:34.400: WARN/dalvikvm(422): Unable to resolve superclass of Lcom/google/api/client/googleapis/GoogleHeaders; (43)
Log of direct call to GoogleTransport.create():
01-27 16:13:11.882: ERROR/AndroidRuntime(16086): java.lang.NoClassDefFoundError: com.google.api.client.http.HttpHeaders
01-27 16:13:11.882: ERROR/AndroidRuntime(16086): at com.google.api.client.http.HttpTransport.(HttpTransport.java:145)
01-27 16:13:11.882: ERROR/AndroidRuntime(16086): at com.google.api.client.googleapis.GoogleTransport.create(GoogleTransport.java:58)
Thanks in advance!
Sounds like your project references are messed up. Try checking the library dependencies.
Related
I'm a English learner,and now I'm using WordNet to make a dictionary APP and you know RiTa is a framework for Wordnet, on the homepage http://rednoise.org/rita/index.html it's saying "now with one API for Java, JavaScript, Node, & Android", I download the jar file rita-1.0.90.jar from http://rednoise.org/rita/download/index.html and test it in Android Studio, and it's not working,the I look up in the source code in rita.wordnet.jwnl.dictionary.file_manager.FileManager.java and find something like java.rmi.Remote and so on,we all know Android does not support java.rmi.Remote. so I'm wondering RiTa really supports Android? if so, where to download? was I downloaded from the wrong page?
Any reply or comments are appreciated
My logcat in Eclipse is like this:
06-14 02:15:44.960: I/dalvikvm(2081): Failed resolving Lrita/wordnet/jwnl/dictionary/file_manager/FileManager; interface 1431 'Ljava/rmi/Remote;'
06-14 02:15:44.960: W/dalvikvm(2081): Link of class 'Lrita/wordnet/jwnl/dictionary/file_manager/FileManager;' failed
06-14 02:15:44.970: I/dalvikvm(2081): Failed resolving Lrita/wordnet/jwnl/dictionary/file_manager/FileManager; interface 1431 'Ljava/rmi/Remote;'
06-14 02:15:44.970: W/dalvikvm(2081): Link of class 'Lrita/wordnet/jwnl/dictionary/file_manager/FileManager;' failed
06-14 02:15:44.970: W/dalvikvm(2081): VFY: unable to find class referenced in signature (Lrita/wordnet/jwnl/dictionary/file_manager/FileManager;)
...... They are all like these
Android does not permit the attempt to load java.* classes other than those that ship with the OS unless passed a special flag to dx.
But it should be possible to pack all rmi classes into a jar file as discussed here.
You were downloading from the right page. FYI this is the link to the latest RiTa.jar and also a quickstart tutorial for using RiTa in Android studio.
I am creating an app tht uses Google Maps API v2. It works fine, except for a little annoying this, when I use the setMyLocationEnabled(true); method, I get a ClassNotFoundException. I can just click "Resume" and the app continues. When running without debugger, there is nothing you can see happening.
This is what LogCat is saying:
09-23 22:39:31.645: I/dalvikvm(2067): Failed resolving Lcom/google/android/gms/location/internal/ParcelableGeofence; interface 4023 'Lglm;'
09-23 22:39:31.645: W/dalvikvm(2067): Link of class 'Lcom/google/android/gms/location/internal/ParcelableGeofence;' failed
09-23 22:39:32.473: W/dalvikvm(2067): VFY: unable to resolve static field 4203 (CREATOR) in Lcom/google/android/gms/location/internal/ParcelableGeofence;
It looks like a missing class in the library, and if I jump into the library project, I indeed do not see that class.
Is there anything I can add / fix to make this exception go away?
I have seen that logcat error before and I noticed it is due to mismatch in my API key between debug and release mode. If you are using separate key store for debug, please make sure you have included both debug and release SHA1+package.name combos in the Google Dev Console.
I am trying to create an android application that is location aware using google play services as it seems that is the new recommended fashion for doing this. I have used the tutorial I found on the android developers site to setup my project. It seems correct and builds fine, however, when the activity just BEFORE the activity that has the google play services dependencies starts I see the following in log cat.
06-18 01:31:04.126: I/dalvikvm(30480): Failed resolving Lcom/example/activities/NewActivity; interface 1045 'Lcom/google/android/gms/common/GooglePlayServicesClient$ConnectionCallbacks;'
06-18 01:31:04.126: W/dalvikvm(30480): Link of class 'Lcom/example/activities/NewActivity;' failed
06-18 01:31:04.126: W/dalvikvm(30480): Unable to resolve superclass of Lcom/example/activities/NewActivity_; (930)
06-18 01:31:04.126: W/dalvikvm(30480): Link of class 'Lcom/example/activities/NewActivity_;' failed
06-18 01:31:04.126: E/dalvikvm(30480): Could not find class 'com.example.activities.NewActivity_', referenced from method com.example.activities.HomeActivity.clickCurrentDonation
06-18 01:31:04.126: W/dalvikvm(30480): VFY: unable to resolve const-class 936 (Lcom/example/activities/NewActivity_;) in Lcom/example/activities/HomeActivity;
Here NewActivity is the activity using google play services that is unable to load and HomeActivity is the activity that calls NewActivity. These errors appear on load of the HomeActivity even before I try to start NewActivity.
I have confirmed that this works normally if I do not include the google play services code.
The only thing I am doing that seems to be different than the norm or than the tutorial is that I am using the android-annotations project which is why you'll see references above to the NewActivity_ which is a generated class this uses based on the code I write in the base class.
Has anyone else encountered this or have any idea how to resolve?
Thanks for any help!
Just re install the Google Play services from SDK Manager and try to link again and clean- build the project.
If still It does not work, download another SDK folder and install Google Play Services and import the Google Play Services project in your workspace and link to your current project.
I don't knw..Its quite strange But It worked for me.
I have a problem with the new ActionBarSherlock.
I have to link it to my project and use it's features (Fragments, etc), in a project that supports android API level 7 and above.
I have created a module in intelij with my project, and I've linked the ActionBarSherlock library project to it. Everything looks good, the project rebuilds correctly, deploy a valid apk to emulator, but when I'm trying to run the application I got something like this:
WARN/dalvikvm(540): Unable to resolve superclass of Lcom/mobileinsight/common/CustomActivity; (134)
WARN/dalvikvm(540): Link of class 'Lcom/mobileinsight/common/CustomActivity;' failed
WARN/dalvikvm(540): Unable to resolve superclass of Lcom/mobileinsight/ui/SplashActivity; (175)
WARN/dalvikvm(540): Link of class 'Lcom/mobileinsight/ui/SplashActivity;' failed
WARN/dalvikvm(540): threadid=3: thread exiting with uncaught exception (group=0x4001b188)`
ERROR/AndroidRuntime(540): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mobileinsight/com.mobileinsight.ui.SplashActivity}: java.lang.ClassNotFoundException: com.mobileinsight.ui.SplashActivity in loader dalvik.system.PathClassLoader#45f352e8
I get the error when the application tries to instantiate an activity that extends SherlockActivity or FragmentSherlockActivity
Somebody can help me with this?
Thanks,
Ark
I am trying to use the EWS Java API v1.1.5 (http://archive.msdn.microsoft.com/ewsjavaapi) in an Android application, and have run into a number of issues.
I downloaded the source, and followed the instructions provided to compile the EWS Java API in Eclipse. In those instructions you are told to download and
add the following pre-requiste jar file dependencies:
commons-codec-1.4.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
jcifs-1.3.15.jar
I did this, and followed the build instructions with produced the following jar files:
EWSAPI-1.1.0.jar
EWSAPIWithJars-1.1.0
Next, I built a brand new Android application, added the appropriate permissions to the manifest, and then added the following source to the primary activity's OnCreate:
ExchangeService service = new ExchangeService();
ExchangeCredentials credentials = new WebCredentials("emailaddress", "password");
service.setCredentials(credentials);
try
{
service.autodiscoverUrl("emailaddress", this);
}
catch (Exception e)
{
e.printStackTrace();
}
I first tried running this application with the EWSAPI-1.1.0.jar file as a dependency. When I did that, I obtained the following fatal error:
Uncaught handler: thread main exiting due to uncaught exception
java.lang.NoClassDefFoundError:
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager at
microsoft.exchange.webservices.data.ExchangeServiceBase.(Unknown
Source) at
microsoft.exchange.webservices.data.ExchangeServiceBase.(Unknown
Source) at
microsoft.exchange.webservices.data.ExchangeService.(Unknown
Source) at
com.meshin.exchange.ExchangeDiscoveryActivity.onCreate(ExchangeDiscoveryActivity.java:40)
From what I've researched, it seems like this error is being generated because Android comes with the Apache HttpClient 4.0, which doesn't appear
to have the MultiThreadedHttpConnectionManager class anymore.
If I instead remove the EWSAPI-1.1.0.jar, and instead use the EWSAPIWithJARS-1.1.0.jar file as a dependency, I get the following error:
VFY: unable to resolve static method 908: Ljavax/xml/stream/XMLOutputFactory;
newInstance()Ljavax/xml/stream/XMLOutputFactory;
VFY: dead code 0x0008-006a in L
microsoft/exchange/webservices/data/EwsUtilities;.formatLogMessage
(Ljava/lang/String;Ljava/lang/String;) Ljava/lang/String;
VFY: unable to find class referenced in signature (Ljavax/xml/stream/XMLStreamWriter;)
And then eventually...
FATAL EXCEPTION: main java.lang.VerifyError:
microsoft.exchange.webservices.data.AutodiscoverService at
microsoft.exchange.webservices.data.ExchangeService.getAutodiscoverUrl(Unknown
Source) at
microsoft.exchange.webservices.data.ExchangeService.autodiscoverUrl(Unknown
Source) at
com.meshin.exchange.ExchangeDiscoveryActivity.onCreate(ExchangeDiscoveryActivity.java:41)
I am assuming because now I am including the HttpClient 3.1 jar and it is conflicting with the HttpClient 4.0 jar included with the Android libraries.
My question is if there is a way for me to use the EWS Java API in an Android project without having to re-write the parts of it which reference
HttpClient 3.1-specific things which are no longer in 4.0.
You can use microsoft's EWS api for android by doing the following steps,
download the source code available in the URL,
http://archive.msdn.microsoft.com/ewsjavaapi
EWSJavaAPI_1.1.5.zip
Make the changes to above api to work for JDK 1.4 in eclipse like remove override annotations e.t.c
Download source code of javax.* package available in below URL,
http://www.java2s.com/Code/JarDownload/jsr173/jsr173_1.0_src.jar.zip
Download source code of stax api available in below URL,
http://dist.codehaus.org/stax/distributions/stax-src-1.2.0.zip
Keep all the sources under the single java project in eclipse
Open the project explorer and select the package which are starts with "javax" and rename to your company name eg: com. Note: Eclipse will ask for all the naming contexts will change then click OK.
Export all the java sources to one single jar file.
Then You good to go to use the jar in Android application with out any problems.
I used the same way explained above and it worked in android application 100% perfectly.
This isn't a useful answer but I've also been struggling to look at the EWS API over the last couple of weeks, with no success.
The main issue I've found is it references a lot of the javax APIs which aren't on Android. There's a hack you can find that explains how to "re-class" these but I've not got it working yet; in addition, the DnsClient references some namespaces that jarsearches only return for rt.jar - the main runtime. And including this in an Android app would just be crazy!
Before finding the API I was trying to use KSOAP to communicate with EWS but again ran into problems - you need to be able to do NTLM and SSL and I couldn't find any way of combining all these with KSOAP in any simple way.
The EWS API looks the way to go (why re-invent the wheel) but getting it working on Android looks very tricky (if not impossible)
Please check this library for the solution