Problem: 20% of users are receiving:
Fatal Exception: java.lang.UnsatisfiedLinkError
No implementation found for java.lang.String com.example.utils.API.getHashString(android.content.Context) (tried Java_com_example_utils_API_getHashString and Java_com_example_utils_API_getHashString__Landroid_content_Context_2)
For other 80% app working perfectly, no exception on my test devices as well.
Can't figure out what's the problem.
EDIT1:
Library loads perfectly on splash screen. No exception on that point.
static { System.loadLibrary("my-lib"); }
EDIT2:
Just reproduced the error. It is absolutely random. App function call works fine, and at some time it starts failing. The only fix is re-installing the app.
Following my comment and later comments from #stanislav-parkhomenko, I'm reposting it as an answer. Thanks!
My comment:
Where is the static {...} block located? A possible reason for this could be that the code is not executed before some calls.
And later confirmed by himself that this was the cause:
The problem was in library initialization. Splash screen run not always, because of sharing functionality, thats why some times library did not load.
Thanks to Xavier Rubio Jansana for advice, which cured my blindness.
Glad it helped!
This error is caused by method signature mismatch between Java and native library you are loading. It is likely that 20% of users have different version of library file with same name. If it is your own library try giving it relatively unique name and load it from absolute path to reduce chance of name conflict.
It looks like it's trying to load a native library, and there isn't support in Android Gradle for native code yet. You should double-check the docs for your library to confirm; I tried to look it up but it looks like it's a commercial library without publicly accessible docs.
You could just put the .so files into jniLibs folder in src/main. This was introduced in AS 0.7.2
As a sample, see this from #CommonsWare, or see this page for official samples (scroll to the bottom of page)
Yes Still no support for native library in Android gradle.Just I followed simple hack.It works great.Check this
Related
Problem
I have tried to replace the Mxnet models in WhatsThis with my own Caffe models that I ported to Mxnet with https://github.com/Microsoft/MMdnn . When I run the application, I get a white screen with no elements and the application crashes. Please advise. Assume that the model is correct as it works perfectly on a PC Mxnet environment. I only changed the model, did nothing else to get this behavior.
Solutions that I tried
Change the input shape ( model is set for 1,3,128,128) - problem remains
Files used
symbol.json
Error log
Log (full error log pasted to pastebin due to stack overflow's limits)
06-20 10:27:24.335 3960-3960/? E/Zygote: isWhitelistProcess - Process is Whitelisted
...
Check that the application works using the models provided in the repository, to confirm that Android can use the MXNet library correctly. Use the instructions on how to build the MXNet Amalgamation here if things are not working with the default models.
You could also try some other methods of converting your model. ONNX is supported by MXNet and given you're converting a Caffe model, you should be able to use the MXNet Caffe Converter too.
I'm looking to write a Linux/Windows/Mac Java HID controller for a simple wireless HID interface device. I've tinkered around with the USB4Java LibUsb library to no avail, and I've been steered in the direction of the JavaHIDAPI.
Unfortunately for me, I really have no idea what I'm doing beyond a pretty decent higher level programming skill set (C#/VB.Net), and switching over to this is killing me.
The directions that I found said that I would first need to compile the HIDAPI library found here. It said it would build something called hidapi-jni.dll (which it didn't).
Anyway, I think this is where I need to go since the HID does nothing but simply sends and receives signals to and from a wireless control (and responds to signals received).
Is there any step-by-step tutorial for using the JavaHIDAPI for this? Or is there a better library? (I noticed that this is a bit... dated).
I tried myself with the following:
static{ System.loadLibrary("hidapi"); }
.
.
.
public static void main(string[] Args) throws . . . {
ClassPathLibraryLoader.loadNativeHIDLibrary();
HIDDevice dev = HIDManager.getInstance().openById(VEND_ID, PROD_ID, null);
.
.
.
}
The issue into which I am running is that (besides the fact that the HIDAPI doesnt seem to be building into HIDAPI-jni.dll) is that the HIDManager.openById(. . .) always returns null. Also, I moved the hidapi.dll that was built into the C:...\Java...\bin directory... or something, I'm sure it's right because there wasn't any unsatisfied link error. It's really frustrating because there doesn't seem to be any newbies guide to Java and HID anywhere.
What am I doing wrong here?
I'm a bit late to answer this question, but I've written a library called hid4java that might solve your problem.
It's based on Java Native Access (JNA) which is a lot simpler than faffing about with complex JNI incantations.
I had to write it because javahidapi is out of date and the underlying signal11/hidapi code has moved on considerably. The older versions of the hidapi library had problems on OS X with attach/detach events which have now been fixed so an upgrade is necessary.
Also I found it impossible to claim a USB HID device through usb4java on OS X so I ended up writing this library to solve that problem.
Hope it helps.
So the issue, I discovered, was with native libraries.
I was able to get the application to work by copying the .dll from the .jar file and referencing it, but more important, I'm going to rebuild the .java class file responsible for loading the library and add the
System.loadLibrary();
call. When the JavaHidApi ClassPathLibraryLoader.loadNativeHIDLibrary(); method is called it doesn't load the library upon successfully writing it out to the temp file which is mildly annoying. Doing this will eliminate the necessity for manually loading the library from a static location...
Thank you for pointing me in the correct direction.
I'm trying to develop a video chat app on java. I found libjitsi, it uses native libraries. There are two example codes which called AVTransmit2 and AVReceive2 (if you want to look: https://jitsi.org/Projects/LibJitsi). But i can't run any of them. I think I don't know how to add native libraries. When i link the native libraries with that:
System.load("the path of the native library")
all of them seems added except one. The one which stops the running with linking error, the one which called AWTrenderer needs links for more libraries. But libjitsi gives me enough libraries for run the code i think. But i still getting linking problem at output. So where is the problem? Can anybody help me please?
Solved. I didn't use system.load for linking the native libraries. My IDE's (eclipse) got a configuration for it. You just selecting the folder which includes native libraries.
I have a rather large shared library file (= 12megabytes) which does not contain any JNI code whatsoever.
When calling System.loadLibrary("some_file") the method never returns and no relevant output is generated. Also, Windows Taskmanager reports that the emulator instance is not hogging all the CPU power.
I have a class with the following code:
static
{
System.out.println("Trying");
System.loadLibrary("some_file");
System.out.println("Works");
}
Here is the output given from LogCat:
I/System.out(534): Trying
D/dalvikvm(534): Trying to load lib /data/data/app/lib/libsome_file.so 0x40643c20
If I upload a native test application that uses the library libsome_file.so and run this from the emulator shell, then the application works.
Is there any method to debug what System.loadLibrary is doing or does anyone have some hints why System.loadLibrary might never return?
I found the solution to the problem myself. I did not use any additional debug tools, but left out some code that was run when the library loaded. The particular code hanged, making System.loadLibrary hang as well.
Adding my solution in case someone else run into the problem. The problem was with some external dependencies (OpenSceneGraph) that were loaded statically in our library. They were only hanging on Android 4.0 and it was running fine 4.2 and up.
So if you have the problem, put a __android_log_print in the JNI_onLoad of your library (if you have one). If it is not called, check all the functions that can be called statically (beware, some might be hidden behind macros) and try to remove them to see if your able to load the library then.
I have no Java experience and prefer Visual Basic; I've found a very nice translation IDE called Basic4android (www.basic4android.com). It works by interpreting a scripting language that's similar to Visual Basic and then using it to generate and compile native Java code. Rather ingenious, if you ask me. In fact I believe I found it from a reference here on StackOverflow.
I'm having some trouble wrapping PayPal's Mobile Payments Library:
www.x.com/community/ppx/xspaces/mobile/mep (scroll down for the HTML Tutorial)
I need to do it in a way that promotes the library's functionality so that B4A can in turn expose it to the Android device (emulator in this case). I've made some halting progress so far, but now I'm stuck on NullPointerExceptions occurring deep within the MPL.
The saga is pretty well described in a thread at their forum:
http://www.basic4ppc.com/forum/additional-libraries-official-updates/8819-looking-download-link.html
Here's my wrapper and the generated code—download here—as only licensed users may access downloads in that particular forum section.
The latest NullPointerException occurs a few calls down from the initWithAppID function. The JD-GUI decompiler reports an internal error when it gets to the com.paypal.android.b.b class, so it doesn't appear to be possible to know exactly what's going on down there.
I'm certain this can be done; I just need to know how to open the proper communication channel between the device and the MPL.
I'm new at Java and I'm new at Android. Quite a combination, wouldn't you say?
It turns out the problem is in the way PayPal bundles their resource files; non-Eclipse projects can't get at them.
More info on the original B4A thread.
Thanks,
Jeff
I think if you ask here about something that generates code for you, you won't be provided with any answers because you can't give any useful source code or something. Also, if you use something like this tool, you never know what it's generating. Also, you can't fix any occurring errors with the generated code... I could go on and on and on...
If you want to use Android the way it's supposed to be used, you'll need to learn Java and Android. If you are good with VB, this shouldn't be that hard. And this is what anyone is going to tell you.