Binding to c# some java-code, that uses .so libraries - java

There are some .so libraries and java code uses them for android.
I compile this java code within android studio to get an .aar file. I need to make binding for c# code fo Xamarin.Android using Visual Studio. So, while binding with java is working good, the java code throws exception:
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader
Through the seeing of full exception message I got that java code can't find .so files. In the Android Studio project .so libs are settled at ./lib/armeabi-v7a/, and the java code works well.
So, the question is: where should I put .so libs in C# binding library? Some inner scent tips me I should put it somewhere -- that's the way libraries work.
I've tried to put .so libraries in directory with my .dll, also deeper in ./lib/armeabi-v7a/, but it actually didn't help -- the exception was the same. I've tried to put them in the directory with my .aar file and also in the deeper directory in ./lib/armeabi-v7a/ but this is kinda of shamanism. it's also didn't help.

the problem was in the way I tried to check the work of program. My Android emulator didn't have the armeabi-v7a support. After I tried to change my emulator settings. it became laggy and very slow. The issue was to test an application on real device.

Related

link dll and jar file to android studio

This question might seem too basic but I'm struggling a lot about this stuff, please help me or guide me.
I downloaded opencv (open source computer vision) libraries and I want Android Studio to be able to use those libraries.
I checked this answer also-How to use opencv in android studio using gradle build tool?
but this answer talks about having opencv-android-sdk and nowadays I think opencv has not anything like opencv-android-sdk , so I couldn't follow that answer.
Now the main point is, what I downloaded and extracted has a folder named java , there is a opencv-320.jar file and two folder x86 and x64, x64 folder contains opencv_java320.dll file. I believe these two files are only files needed to get opencv libraries in Android Studio. But I don't know how it can be done. Please help me.
You should not be using any dll or jar file that is not specifically for Android.
OpenCV has an Android version: http://opencv.org/platforms/android/
Follow the instructions and example there in order to use it.

Android APK invalid? Didn't find class "AndroidLauncher" on path: DexPathList

I'm getting the following error when I try to run my App on my SmartPhone:
Didn't find class "munyul.game.android02.android.AndroidLauncher" on path: DexPathList
Due to HD issues, I was forced into rebuilding my machine and setting up my developed environment again. After a lot of messing around, I have the following installed and working:
Java 1.8
Eclipse Neon
libGDX
Android SDK Manager
The Android App in question was almost finished, but now that goal seems like a long way off :(
I used libGDX to create a new project, and then I copied the old code into the new project - this is where things got messy.
I had to fix several errors caused by changes in libGDX, which was easy. I then also had to fix several errors caused by changes to Google Services, this was not easy! I eventually read about the new m2repository folder, then I searched for and found the class files needed (play-services-ads, -base, -basement, -games and -plus, inside .aar files), placed all the classes.jar files into their own directory within the android/libs project folder, finally adding references to them from within Eclipse - now everything compiles and looks good (should these .jar files be checked for export? - see edit)
Finally, I had to make one more change; the old project/code was created with a package: munyul.game.android02.android, but the new only had munyul.game.android02, I added the missing package to the new and also updated the AndroidManifest.xml file (maybe this is what went wrong!?).
I've checked the code and manifest and everything looks correct, but when I run the App it instantly crashes with the above mentioned error.
Also, I've checked the Order and Exports for the android project, the boxes that should be checked are.
Anyone know what else I could try?
EDIT:
As a test, I checked the Google Services JAR's for Export, and now I'm getting a different error:
Could not find class 'android.support.v4.util.ArrayMap', referenced from method
com.google.android.gms.common.api.GoogleApiClient$Builder.<init>
I'm starting to think that my error lies with how I resolved my Google Services issues - is there a better way of linking the missing classes? Somehow adding them via Gradle?
EDIT #2:
I migrated the entire project to Android Studio - now the APK installs and runs correctly on all my devices.
Honestly, I would have prefered to stick with Eclipse, but it seems like that is no longer an option - HTH
Check your AndroidManifest.xml for the correct application class (or none if you are not overriding.) The AndroidLauncher is part of the "instant run" feature available in Android Studio and is automatically injected by gradle into the manifest file.
Eclipse is no longer a supported development toolchain - you'll want to do your migration to Android Studio (or IntelliJ) sooner rather than later.

Can`t run on Android device, because of librabries

I'm launching a game on Android device and getting this error. I`m using up to date Android version, also libgdx.
The library 'jinput-platform-2.0.5-natives-linux.jar' contains native libraries that will not run on the device.
The following libraries were found:
libjinput-linux.so
libjinput-linux64.so
Please help me understand what may cause the problem.
*.so files are native assemblies that are built for a particular architecture. If those *.so files were not built for android (and it seems as if they are not given the error) they will not work.
If there isn't a version for android already built, you can try to write an android version. This other SO question may be of assistance.

Implementing and using SoundTouch class (Java Android)

I've been trying to use the library SoundTouch in my android app in order to change the tempo of an mp3 file.
I've managed to compile the library following the steps outlined here: http://www.surina.net/soundtouch/README-SoundTouch-Android.html
My question now is how do I import and use the compiled library in my android project in Eclipse?
From following the steps in the link above I've ended up with .so files that I've added into the libs folder of my project. I've also changed the build path to include this new library.
The library is now showing up under "referenced libraries" so I'm guessing I'm some where on the right track?
In my java file I've tried importing the library like this:
static
{
System.loadLibrary("soundtouch");
}
The program builds and runs fine but I don't think the library is actually being loaded as I can't reference any of soundTouch's methods.
Any help would be much appreciated!
The JNI file provided with the SoundTouch library is merely a demonstration and does not provide any means of using any of SoundTouch's features in an Android app from Java.

Android shared library which is not JNI based

I am developing a library for Android applications which does not use native code (JNI). I have tried suppling the library as an external jar in my Android projects but this method does not include the library contents in the apk and thus throws class not found errors when run in the emulator or device. I have also tried creating the library as an Android project in itself and this does work, but only for public static properties (not methods). With the library and application both being in separate apk's I can see that the VM notices references to the library and can read some properties, but when an attempt to instantiate a class in the library is executed I get class not found even though I can read the public static properties from it (very frustrating!!).
I realize that Davlik byte code is not the same as Java byte code but I am having trouble even finding good information about how to solve what would seem to be a very simple issue in Android. I am looking into the old PlatformLibrary stuff right now but I am not convinced this will work either since the sample has been removed from the Android site :(
So help me out if you can, if I find the answer before this happens I will share it.
viva la Android!
I have tried suppling the library as
an external jar in my Android projects
but this method does not include the
library contents in the apk and thus
throws class not found errors when run
in the emulator or device.
Put the JAR in your libs/ directory, and it will automatically be included in the APK.
This sample project from one of my books shows using the BeanShell JAR this way. Also, all of the GitHub repos starting with "cwac-" on my GitHub page are projects designed to build JARs to be included in Android projects via the libs/ directory.

Categories