I am new to Android development. I'm working on an project which involves using stubs for web services. When I try to use it, I get the following error:
I've been stuck here for a week, so some help would be highly appreciated.
It seems that there is some packaging or deployment issues with the included libraries that you use in you project. This error is thrown when the Java Virtual Machine or a ClassLoader instace try to load the definition of the a class but cannot find it anywhere. In most cases, this occurs when something is messed up in your project configurations but i cannot tell what from the information provided. A solution would be to configure your project from the scratch since most of the times this is easier than finding what causes the problem. Also in case you had an older version of ADT (<17) the answer of this SO question might be usefull. Finally, if you are importing any javax libararies(or libraries that have javax components in them), this maybe the source of your problem since Adroid does not support the javax library.
Related
I'm working on an app where I'm in need of building a very small and minimal plugin container.
Below are the things I'm trying to achieve.
Application is divided into smaller plugins packaged as Jars.
Plugin container should get them and load all jars.
Each plugin should not interfere with other plugins and should run on it's own along with it's dependant libraries. Basically all plugins should be isolated at runtime.
I tried using OSGI container, but it adds high complexity. Also many of the third party libraries which are not compatible with OSGI creating problem which is taking lot of time to debug. Also checked out Spring Boot, JPF etc. and not very interested. So thought of using very small homegrown plugin framework.
I have no clue on how to do and where to start. Please anyone can point me in right direction where I can get detailed information on this.
Thank you in advance.
If you truely want something minimalistic, have a look at Java's ServiceLoader class.
Here's a tutorial.
Firstly, apologies if I have not included all the required info for this question to be answered. I am somewhat new to Android development and am still getting my head around the build tools, API levels etc. So please let me know if there is any additional info I should provide to help you help me!
After updating my Android project compile sdk version to 27, I realised that version 27.0.2 of com.android.support:support-v4 no longer includes AsyncTaskCompat (that class has been deprecated & removed).
I have a third party library that is not open source, not easily replaceable, is no longer supported and still uses AsyncTaskCompat.
Since AsyncTaskCompat is open source, I was thinking I could simply reintroduce it somehow by redefining it in my project.
I've tried redefining it under my project in com.android.support.v4.os but even though the project compiles without any issues, when I run the section of the app that uses the third party library I get a crash with a class not found error for AsyncTaskCompat.
Is there something obvious I might be missing?
No need to add a specific Android Library module.
Only add the classes bellow to your project using the package name "android.support.v4.os":
AsyncTaskCompat
AsyncTaskCompatHoneycomb
Answering my own question here after another day of hacking away.
It is in fact possible to re-implement these deprecated/removed classes in a way that the dependency will be able to use it.
The steps are described here in case anyone needs it in the future
Create a new Android Library module for your app
Reimplement the missing classes using the appropriate namespace
In my case I needed to reimplement android.support.v4.os.AsyncTaskCompat which is open sourced so all I had to do was copy the code from source.
Add the module as a dependency of your main app module.
I'm running into a strange problem in Android Studio. I'm also using latest JDK. I can't seem to import the following :
javax.xml.stream
javax.xml.transform.stax
They both are unavailable and I don't know why. In a non android project I'm able to import these. Any clue why these are missing in android?
If not, the simple solution is that I added these dependencies from maven. But after running I'm getting this error:
"Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library.
Android doesn't use the same Java JDK as what you use for a desktop or server app; it uses its own implementation of the JDK, which adds the android.* hierarchy but leaves out some packages that are in the standard JDK, especially in the javax.* Java extensions. Unfortunately for you, javax.xml.stream and javax.xml.transform.stax are among the things they didn't choose to implement. Moreover, the Android runtime won't allow you to load any java.* or javax.* classes from an external JAR file for security reasons**. This answer may describe the situation a little better.
Your best bets are probably: 1) use a different third-party library specifically built for Android, such as SimpleXML; 2) look for a repackaged version of the libraries, like this JAXB effort; or 3) use a tool like Jar Jar Links to do the repackaging for you.
Also see this excellent guide on parsing JSON and XML in Android.
** Note: I can't find any documentation from Google to substantiate this; it's just a commonly repeated "fact". If anyone can point to an authoritative statement about Android's handling of third-party java[x].* classes, please comment with a link, or edit this answer.
I am facing this unique problem, i have some custom libraries deployed in weblogic lib folder and some of them have same package structure and even some classes have same names. But these libraries are being used in different applications, so applications dont give any compile time error. But in a shared environment, they are causing trouble. Any suggestion on how to fix this with minimum changes. I am using weblogic 11 server and working with EJB 3.0 applications.
The problem is at level of design. A good library or application should have a custom package not reused by other libraries or applications.
The best solution is to refactoring your code changing the package names. Don't limit the changes to the conflicting classes, but change the whole package. It should be simple with modern ide (Eclipse, IntelliJ).
For next projects remember to use always a syntax for packages like the following
com.yourcompany.yourproject.specificpackages
this will guarantee that no class will go in conflict with others.
I have gone through the previous thread on the same topic
After reading that i tried to use the same code. I am very new to Eclipse plugin development. I tried to see the given example links but couldn't find the correct thread.
I have a similar requirement. I tried to develop a plugin following this link
Should i compulsory develop a plugin or is there any way where i can run it from java main method.
Thanks,
Vamsi
Basically, you have to write an Eclipse plug-in, as the suggested code re-uses existing features only available in an Eclipse plug-in environment.
For the referenced code to work, you have to maintain a plug-in with the dependencies org.eclipse.core.resources plug-in, and you also have to provide some functionality to execute this code (e.g. a platform command, as in another the mentioned vogella.de tutorial.
In theory, it might be possible to do it in plain Java code, but in that case it would make more sense to do it by directly editing the metadata files - and that is a way I do not recommend.