I'm trying to create a plugin for a java library (in .jar file) to Phonegap users.
Currently, my plugin connects two methods from my library: one that uses network operations and writing to device memory and one that runs a new activity.
The one that uses network works, no problem. However, the one that runs a new activity fails in run-time with the NoClassDef.. error.
Classically, this error comes from either not declaring an activity in the manifest or from the class actually not being there (i.e., problematic build, etc..)
Post compilation & build with phonegap, i can see two things:
1) my activity is defined in the final manifest (with correct path)
2) the class is present (inside the .jar) - also, the rest of the classes from my jar can be found to be running in the stack of the error.
I'm really lost as to what directions to explore, i'm running out of ideas. Any suggestions? If you need more info let me know i'll post it up here.
I'm running the latest phonegap through npm (downloaded two days ago)
Work is done on a macintosh
The jar i'm trying to translate is working 100% under any other circumstance.
The java code in the jar is accessible since method 1 works & method 2 starts running until it tries to start an activity.
Phonegap build produces no errors (i'm running on verbose)
I'm testing on a nexus 5 Lollipop
The jar is inside the final build
I believe the activity is declared in the final build's manifest (my apkTool doesn't smoothly show the manifest as it fails completing its process)
Any help would be welcome, hoping it's not a duplicate as i've done quite a research.
Ok, all through a terrible weekend of self hate and pitty I found the reason for the NoClassDefFoundError.
A dependency needed for the activity I was trying to open was not present. This error is usually known to Android developers as most commonly happening when an Activity is not defined in the manifest file.
However, returning this error because the class failed finding its dependencies is really poor. That's absolutely not an indicative output.
Anyway, thanks for those who tried to help, I hope this somehow helps somebody, someday.
Related
I am quite new to programming, so I have a lot of difficulties with things that may seem simple.
I work on an app that reads an Access database and lets the user search trough it. I am programming it with eclipse and javaFX.
When I run it with Eclipse it works fine, however I have tried to export it in a runnable JAR file to be able to run it on any computer, and when I try to run the JAR, nothing seems to happen.
I have added an argument :
--module-path "C:\Users\calon\OneDrive\Documents\Code\JavaFX\openjfx-17.0.2_windows-x64_bin-sdk\javafx-sdk-17.0.2\lib" --add-modules=javafx.controls,javafx.fxml, which from what I understood is not added to the JAR, so I have to add it when I want to run it. However this argument is relative to my file system and wont work on another computer. I don't know how I can change it to make it work for everyone.
Also, I have tried to convert it to Maven, and when I run it, it sends this message : Error occurred during initialization of boot layer java.lang.module.FindException: Module henriGaussenDataBase not found.
The project can is at https://github.com/Anthony-Calonne/HenriGaussen.git .
I don't know what to do to make it work, I have searched different ways to do it but did not understand everything I have read on this subject.
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.
After adding android-support-v7-appcompat and google-play-services_lib to the Android project application starts to crash right after start with
java.lang.ClassNotFoundException exception.
I read all questions on StackOverflow related to this problem, and opened Eclipse -> Java Build Path -> Order and Export and verified that:
Android Private Libraries, Android dependencies, Google Play Services.jar are checked and Android API unchecked here.
So apk built locally works fine. But on TeamCity side apk which we get as result crash with exception. So I suppose, that I need to add some changes to Ant script regarding android-support-v7-appcompat.
Please suggest steps which I can try.
ClassNotFoundException is exactly that. A class that is references cannot be found. When working with third party libraries, you must ensure that their dependancies (if any) are also included in your class path.
Without seeing the actual stacktrace, its difficult to narrow down the problem, but I would check if the dependancies of the third party libraries that I am adding are also included in the class path.
Hope that helps.
Hello im making an generic app that is configurable by xmls and files on res. Im trying to make differents apks from the same source of code. The problem is that im triying to do this by command line interface and i still dont find a way to change the package name and then build it in release mode.
I created my custom build.xml ant file and I tryed this solution,it generates 2 apks: MainActivity-debug.apk and MainActivity-debug-unaligned.apk but didnt work for me since the apk just built on debug mode and didnt even ran on emulator throwing [ INSTALL_FAILED_INVALID_APK].
So is there a way of doing this? The main problem isnt about debug or release mode since i think i just will have to use ant release command, is about creating an apk with different packages names so i can have both signed and running in same device.
Thank you!
If you set your project as a Library project, you can use a facade style Project with it's own AndroidManifest.xml and overriding /res values to create a "custom" set of projects which derive from your main "Library" project.
Facade projects created in this way act the same in terms of functionality but can have different styles, package names, internal id's, colours, images (or even expose different intents or receivers).
As commonsWare proposed i used Gradle for this solutions.
I used this tutorial for Gradle with android.
I used this answer for building apps in release mode
I used flavors also as commonsWare said, read this
Thanks a lot!
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.