java.lang.VerifyError in YouTube service initialization - java

I'm trying to develop app working with YouTube. First, I downloaded gdata libs from
https://code.google.com/p/gdata-java-client/downloads/list (client, core, media and youtube), then tried to instantiate YouTubeService as in Google's tutorial:
service = new YouTubeService(id, key);
But when I tried to launch my app I got this:
ERROR/dalvikvm(5289): Could not find class 'com.google.gdata.data.media.MediaStreamSource', referenced from method com.google.gdata.client.media.MediaService.getMediaResource
ERROR/dalvikvm(5289): Could not find class 'com.google.gdata.data.media.MediaMultipart', referenced from method com.google.gdata.client.media.MediaService.insert
ERROR/AndroidRuntime(5289): FATAL EXCEPTION: main
java.lang.VerifyError: com/google/gdata/client/media/MediaService
libs are attached to project and I can see those "missing" classes in them, and my IDE can see them, but there's something strange happens in runtime. Any ideas where I'm spoiled?
P.S. It's Android app, if it matters.

Solve the probem by adding the following libraries:
activation.jar
additionnal.jar
android-support-v4.jar
guava-r07.jar
mail.jar
beside the gdata libraries:
gdata-client-1.0.jar
gdata-core-1.0.jar
gdata-media-1.0.jar
gdata-youtube-2.0.jar
Not need authetntication.

Related

How do I get Google's open source apps (android.googlesource.com) running on Android Studio?

In other news, I spent half a day - being a beginner and all - trying to import DeskClock into Android Studio, so I could study it better, instead of crawling dozens of source code files.
Cloning the project didn't work out, what with missing gradle files, and Android Studio not recognising it as an Android app, therefore not loading necessary configurations that'd enable one to run it.
Next line of action was to try creating an Android project, deleting MainActivity.java & activity_main.xml; copying over files from DeskClock (com.android.deskclock), making necessary refactoring to avoid provider & package name conflicts. Did so and upon running the app, I got errors here and there, related to missing dependencies, which I added and tried running again; app installs, but keeps crashing due to errors I attribute to multiDex being disabled; I enabled it (via build.gradle, by setting multiDexEnabled to true, extending MultiDexApplication in DesktopClockApplication instead of Application), but still face the error::
E/hengnet.decloc: [qarth_debug:] get PatchStore::createDisableExceptionQarthFile method fail.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.blogspot.thengnet.declock, PID: 22671
java.lang.RuntimeException: Unable to instantiate application com.blogspot.thengnet.declock.deskclock.DeskClockApplication: java.lang.ClassNotFoundException: Didn't find class "com.blogspot.thengnet.declock.deskclock.DeskClockApplication" on path: DexPathList[[zip file "/data/app/com.blogspot.thengnet.declock-rXBKN9OfqNprzSTBu6qqMg==/base.apk"],nativeLibraryDirectories=[/data/app/com.blogspot.thengnet.declock-rXBKN9OfqNprzSTBu6qqMg==/lib/arm64, /system/lib64, /product/lib64]]
What is the way IN?
What do I need to set up to get Google's open source apps running?!
Inspiration: How to import an Android Studio project from android.googlesource.com?
My purpose it to build a decent scheduling app for Alarm & Calendar, so anything besides would play out anyway. Thanks!

How to identify which missing Java Libraries to make JAXB to work?

My Tibco BW 6.3.2 project invokes some Java Code that works on my machine, but I'm having issues on the server.
At first, I got this error
<CausedBy> java.lang.ClassNotFoundException: com.sun.xml.bind.v2.model.annotation.AnnotationReader cannot be found
So Googled it and added jaxb-impl.jar and jaxb-core.jar(JAXB v2.2.11). Again, it worked on my machine without adding these to the classpath. But once I added them, I got this error on the server:
<CausedBy> java.lang.RuntimeException: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
<CausedBy> java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
Again, I Googled it and added xercesImpl.jar. But now I'm getting this on my machine & server :
<CausedBy> java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration
After some google searching, I've determined there are 2 xerces jars in my project, but I can't find the second one. Any thoughts on how to do that? OR does anyone have a different solution?
Side note, the java code works perfectly fine in Eclipse without any of these libraries added to the class path. (All devices are using Sun JDK 1.8.0_92)
EDITED:
I removed all the jaxb libraries I added and defined them in the Module Descriptors -> Dependencies -> Imported Packages.

FATAL EXCEPTION: main java.lang.NoClassDefFoundError: external library.jar.class Android studio

I am developing an android app which process speech and I have speech basic project (dependency for android project) ready on JAVA so I compiled JAVA project in eclipse in JAVA 7 compiler and exported that java project as a runnable jar.
I put this jar into my android studio project's libs folder and by right clicking selected AS A library, I got build successful message. But when I try run the android project it gives me error saying,
FATAL EXCEPTION: main Process: in.automator.automator, PID: 4242
java.lang.NoClassDefFoundError: jar_filename.Storage.class_in_jar_file
but the said class is there in the jar file, the only doubtful thing is the mentioned class file looks something like this
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import marf.util.InvalidSampleFormatException;
public class MARFAudioFileFormat extends AudioFileFormat {
....
...
....
}
It refers javax.sound.sampled, so possibly that might causing the problem.
I tried searching on the google for the problem but didn't got the solution which can resolve the issue. I tried everything.
I am using JRE 7 in android studio and exporting java project in Compiler & itself.
How to resolve this error?
Thanks in advance.
You are correct, the problem lies in the fact that the library you're trying to depend on, in turn depends on the javax package hierarchy. Android does not provide javax, so those classes don't exist at runtime (even though they do exist in your computer's JDK, so your compiler doesn't complain - it's basically the same as not having a particular DLL installed that a program on your PC needs).
The NoClassDefFoundError is being thrown on the class that first references the invalid class dependencies, which is probably what's confusing. That class may indeed actually exist in your jar, but it requires classes that don't exist in order to complete its definition - so in effect, your class is not fully defined.
The only way around this is to figure out a way to do whatever you're after, without the javax namespace. I have heard of a few attempts to try to port javax.* into Android, but they never end well - many of the javax classes end up boiling down to native calls, which also won't exist on Android.

Why do I have java.lang.ClassnotFoundException while implementing location listener? (using ECLIPSE)

I know that similar questions have been on SO and I have read through and tried to implement the solutions mentioned but nothing is working. The specific problem is like this (using ECLIPSE):
I am trying to implement location awareness in one of the activities (triggered through menu selection) in my app. As long as my code looks like,
"public class MealHistoryActivity extends Activity {...}",
I don't get any error. As soon as I modify it to
public class MealHistoryActivity extends Activity implements ConnectionCallbacks, OnConnectionFailedListener, LocationListener {..",
it throws in the following error:
E/AndroidRuntime(5027): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.package.activities.MealHistoryActivity" on path: DexPathList[[zip file "/data/app/com.package.activities-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
What I have tried:
Adding up the library projects (support library as well as google play services) and cleaning all the projects.
Including Android Private Libraries for the application as well as the library projects.
Double-checking the API key in android manifest as well as the SHA-1 fingerprint key associated to it.
Using all the internet and network permissions in the manifest that are needed for location services.
Would greatly appreciate any ideas on how to solve this since I am stuck on it for the last few days!
The error suggests that the classes from the google-play-service project are not loading.
Make sure you are referencing a copy of the project in your workspace, and not the copy that is in the sdk directory. Try doing that or deleting the google service project from your workspace and redoing the steps in this guide.
Another possible cause for this is version mismatch. If your device's version is less than the version specified in the above mentioned guide than the google services project will not install on your device at all.

Htmlunit on Android application

Has anybody gotten HTMLUnit (or HtmlUnitDriver) to work on Android apps?
This is the problem: I am getting the following error message:
11-26 16:27:26.617: E/AndroidRuntime(1265): java.lang.NoClassDefFoundError: org/w3c/dom/css/CSSRule
This is what I did: I tried adding adding references to the jars listed in the following link (under both Project Dependencies and Project Transitive Dependencies - compile only, excluding test jars):
http://htmlunit.sourceforge.net/dependencies.html
However Eclipse kept crashing, then I found a few questions saying some jars are already contained in the Android SDK:
xalan, xercesImpl and xml-apis
HtmlUnit on Android
HttpClient
Android Programming HtmlUnit
So I removed the references to these jars keeping only the following:
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-io-2.0.1.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
cssparser-0.9.5.jar
htmlunit-2.9.jar
htmlunit-core-js-2.9.jar
httpmime-4.1.2.jar
nekohtml-1.9.15.jar
sac-1.3.jar
httpcore-4.1.3.jar
It was at this point when the app was able to run but when the following line of code was executed I started to get the error:
final WebClient webClient = new WebClient();
11-26 16:27:26.617: E/AndroidRuntime(1265): java.lang.NoClassDefFoundError: org/w3c/dom/css/CSSRule
I did a web search and found that xml-apis-1.3.04.jar contains org/w3c/dom/css/CSSRule so I put that reference back to the project but the app wouldn't build at all saying the same error message described in the first link above:
[2011-11-26 16:39:52 - Myproj] Conversion to Dalvik format failed with error 1
Could somebody please shed some light on this?
xml-apis-1.3.04.jar contains core classes. You have to modify the jar and delete those classes.
Please note that, at least in current ADT version, you are getting a message explaining the problem:
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
Just as ULsies stated in the comments Htmlunit does this ==> HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.
which is exactly similar to webview widget provided inside the android sdk you dont need any other extra jar to open a web page inside your activity
as per google android documentation
A WebView is a View that displays web pages.It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
add this to your activity layout xml file.
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
and this to your activity class file..
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.loadUrl("http://www.your url .com");
more on this here: http://developer.android.com/guide/webapps/webview.html

Categories

Resources