Hey guys I am working on a Scala/Java project and we are using OpenCv to image processing. I have been stuck for several days trying to import the library, I went through different errors but right now the one I am having in the last attempts is
Uncaught error from thread [application-akka.actor.default-dispatcher-9]: org.opencv.imgcodecs.Imgcodecs.dicomJpgMatRead_0(JII)J, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for ActorSystem[application
java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.dicomJpgMatRead_0(JII)J
Please, I would be very grateful if someone could help me. I don't know what else to try.
Thank you in advance!
This generally happens when your code has access to the class when you compile but not when you run. In many IDEs it's due to where you are placing the classes or how you are deploying the code.
UnsatisfiedLinkError refers specifically to a DLL (or Lib in Linux) that it isn't finding at runtime. Does your running code have access to the dynamically linked library? (obviously not, find out why)
Hey guys thank you for the response. I try (at least I think) all the solutions I found including the onces that are in the link you mentioned #zoranjeremic.
I am working with a Java project that has inside one class "JDicomImageLoader" that is the one who needs the opencv library. Inside of it I have a method call setup:
Now I am using a System.load with absolute path but I also try doing System.loadLibrary with the respective "java.library.path".
Then I am compile this Java project (sbt compile) and publish locally (sbt publishlocal) to use in my Scala project.
Related
I recently upgraded to IntelliJ 14, then added Scala support.
My main files stopped running. For example the GUI file, which has no errors and is a totally self contained hello world style for testing this error:
Exception in thread "main" java.lang.ClassNotFoundException: GUI
It makes no sense and I'm pretty frustrated that the IntelliJ devs are slacking in not auto-detecting a solution to this. I have tried everything to fix it. From settings, compilers, to making the project from scratch.
I only had a bit of luck when making it from scratch, but as soon as I started to add my other files (files that were not even being used!) it starts with the error.
It seems that any files outside of the original project module (when creating a new project to test fix) will not run giving ClassNotFoundException.
This may be related to my other question: https://stackoverflow.com/questions/27516673/cannot-run-file-located-out-of-main-module-intellij-14-java-scala
Sample View of the problem
I had the same problem and was able to fix it by right clicking the directory my class was in, and clicking Mark as sources root. This should make your class discoverable and able to run.
Solution
Turns out that Make, No Error Check does not work the same for scala as it does for Java.
Errors in the scala files will cause an ambiguous error message on run, with no clear link to the error.
Fixing the scala files fixes the error.
In my case, the solution was at the JDK and java level.
When I set JDK 14 this error occurred.
So when I work with a scala project, I set java 8 everywhere in the project(module) settings and in the configuration of the main method.
In project(module) settings section: Project, Modules, SDK's
In main method settings: JRE
Im trying to run eclipse on processing so i can export my sketch as a jar which can run on any operating system. But i'm getting the following error, Here i'm using an extension called proclisping. Has any one got suggestions why my lib cant be found? Im using processing 2. If anyone has any other way where i can get my scetches to run on any machine with all my images, it would be much appreciated.
Thanks in advance!
First, you're trying to run Processing in Eclipse. Next, have you checked these instructions? Finally, you may prefer the Eclipse plugin proclipsing (NOTE currently proclipsing is BETA).
I'm following a basic tutorial for the android jni development at http://permadi.com/blog/2011/12/running-android-ndk-examples-using-eclipse-and-sequoyah/. Before moving to problem I solved building error by setting "cmd F:\Android\android-ndk-r8\ndk-build" to build command.
Changed build command
Hope it's not wrong. But now it gives following error. Iv'e added logcat here.
I can see two exceptions are shown here as java.lang.UnsatisfiedLinkError and java.lang.ExceptionInInitializerError. I can't figure out what is really caused. It is said that you can fix UnsatisfiedLinkError by adding libJniTest.so to correct path. But i can't find it. I've run a search on my windows machine to find libjnitest.so but it is nowhere. Is it the problem and if it is someone can say where it should be. There are more than thousand questions as same as this but i'm no where to figure it out solution after spending several hours.
Here is my code.
Java code
Please note that iv'e commented native function call but i can see problem is with the loading library.
Native code
Here i add the folder structure.
You need to run $(NDK)/ndk-build from the project's main directory in order to create the .so libraries, which should be automatically copied into the libs/ folder.
This assumes that you have a proper jni/ folder with an Android.mk in it alongside your source code.
You may want to see the hello-jni example from the ndk samples directory for an official example with all the requried pieces.
Clean and build the project again. It will be resolved. I solved it by just that.
So I ran into a problem today while working on my Android program. I have a class that turns that an XML string into a Java object (third party) and it works fine in as a regular java project but on Android I get this weird error:
06-21 22:44:26.402: DEBUG/App(259): java.lang.ClassNotFoundException: com.package.mycode.Class in loader dalvik.system.PathClassLoader#4001b500
06-21 22:44:26.402: DEBUG/App(259): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
I hide my application name and my package for obvious reasons but I was wondering if anyone has ever encountered problems like this. Class is in the correct package, which is a library I have added. Other classes that I reference before are there and those can be made. Are there any other reasons a ClassNotFoundException is thrown?
Thanks,
Jake
private static void fixClassLoaderIssue()
{
ClassLoader myClassLoader = MyClass.class.getClassLoader();
Thread.currentThread().setContextClassLoader(myClassLoader);
}
This is the code I currently have that I believe fixed this problem. MyClass is just a class I have in my project. Like I said, a co-worked showed it to me, but it seems pretty straight forward.
Are there any other reasons a ClassNotFoundException is thrown?
IIRC, it can also be thrown if some other class in the static dependencies of "com.package.mycode.Class" cannot be loaded, or if there is a problem during static initialization. But these should show up as a nested exception ... the first time you attempt to load the class.
Android has not all Java classes available that are available on a normal machine.
There are some classes missing that could cause this error. But this should be already be shown at compile time. Look at this list to see which classes are supported and which are not supported.
Again I'm only guessing because the compiler should see the missing classes.
For an android app, I'd same issue with an external jar file. In my case the solution was to move the jar from "lib" folder to the android default "libs" folder.
When the jar was in lib folder (was added to build path as well), while there are was no build issue in Eclipse, the app was giving ClassNotFoundException at runtime. Once I moved the jar to "libs" folder, the jar started appearing under "Android Dependencies" and app started working fine.
These are some of the other discussions about the same topic.
Adding a library/JAR to an Eclipse Android project
Android: What is the folder name of the jar files (LIB or LIBS)?
How to specify lib folder for JARs when using Android-generated ant build file?
i had a problem starting an aynctask. it used to work just fine but then i added
line = StringEscapeUtils.unescapeHtml4(line);
(its a commons.apache.org library) to the asynctask then lots of problems. it compiles ok but when i tried to run, it said class not found on my asynctask class. but it i hit resume it kept going in the async task, then it died.
so i guess the problem is StringEscapeUtils isn't installed properly, but i had no way of figuring that out from the error messages i was getting.
Are there any other reasons a ClassNotFoundException is thrown?
In my case, I got a ClassNotFoundException for my main activity when building the apk with eclipse but did not have any problem when building with maven.
The problem was that my main activity was implementing an interface from a plain java project "POJO library". In the Android project>Properties>Java Build Path>Order and Export I had to tick the box to export the "POJO Library". After cleaning the project, the interface was included in the classes.dex in the apk and the problem was solved.
I was directed here when trying to understand the problem, and I hope it will help somebody else in the same situation.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
NoClassDefFoundError - Eclipse and Android
I'm seeing this question is getting asked a lot in many different contexts. Perhaps we can set some strategies for locating and fixing it? I'm noobish myself so all I can contribute are horror stories and questions, sorry...
It seems this is thrown when a class is visible at compile time but not at run time... how can this happen?
In my case I am developing an app that uses the Google APIs, in Eclipse, for the Android platform. I've configured the Project Properties / Java Build Path / Libraries to include the gdata .jars and all is well. When I execute in the emulator I get a force close and the logcat shows a NoClassDefFoundError on a simple new ContactsService("myApp"); I've also tried a new CalendarService("myApp") with the same results.
Is it possible or desirable to statically bind at compile time to avoid the problem?
How could dynamic binding of an add-on library work in the mobile environment anyway? Either it has to be bound into my .apk or else I need to "install" it? ... hmmm.
Advice much appreciated.
It seems this is thrown when a class
is visible at compile time but not at
run time... how can this happen?
The build classpath may include JARs that are not being packaged into the APK.
Is it possible or desirable to
statically bind at compile time to
avoid the problem?
It is possible, desirable, and necessary.
Outside of Eclipse, you just put the JARs you need in libs/ in your project, compile with Ant, and you are done.
Inside of Eclipse, one pattern I have had students use with success is to put the JARs you need in libs/ in your project, add them as JARs to the build path (note: not external JARs), and they get packaged as part of the APK. Note, though, that I do not personally use Eclipse, and so my experience with it is limited.
For those having problem I was having the same error with my app. what I did to solve that was create a new project and copy my resource and source folders along with my manifest file into the new project (I deleted in advance those within the new project created) and voila.
When I got this, the problem was actually deeper in the queue; Dalvik converter had failed to convert some of the referenced libraries and still Eclipse allowed me to launch the project.
Check the Android SDK console to see if there are any errors reported.
In my case, I'm using my own library (MyLib) shared between 2 apps. App A was closed when I added a new class to the library.
When I opened App A to work on it, Eclipse recognised the new class, and I was able to reference it. However on running I got the error.
It turned out that the imported library folder in App A (named something like MyLib_src) didn't reflect the changes made to my library project (MyLib).
To solve this I refreshed App A, the changes reflected, and Android could build my project correctly.
I have found no reference to this version of the problem, so thought I would add it to this list.