NDK installation is required for reuse NDK code? - java

I have downloaded code http://code.google.com/p/aacplayer-android/downloads/detail?name=aacplayer-android-r25.zip&can=2&q= for playing AAC file in ANDROID
and below is image of that code in eclipse
Here you can see that there is jni folder and libs folder in LIBS folder also contain .so files
Currently i have not installed any NDK and i have imported this project which is working fine...
but if i use this files and code into my project should i have to install NDK?
I have copy and paste this jni and libs folder to my application, now what should i have to do! How to tell my apps that this is the native code!
my apps folder structor is (after copy paste) below

If you do not want to rebuild the .so files you should not need the NDK. Eclipse/Java/Android will handle them as fine as native java libraries. You need the ANdroid NDK if you want to be able to compile c/c++ code for the android platform.

Related

Is it possible to run a jar file in an android application?

I am a begginer in android and I want to develop an application which show a list of jar files to user and user can choose one of them and run it. Is it possible to run a jar file in an android application? (not as a library)
Nope we cannot run a jar file on android devices, You see we have .apk to install it on our android device. But not .jar, Also Android uses the Dalvik VM, where as you need the Java VM to run a jar-file. So you can run jar on android.

Google Or-Tools : UnsatisfiedLinkError

I have created a spring application which uses google or-tools. For that, I am importing jniortools using System.loadLibrary("jniortools"). when I provide the .dll file and run the war file it runs perfectly. But when I provide the .so file path in lib, I get the unsatisfiedlinkerror.
Taken from here, a solution for using or-tools over Intellij:
To make it work using Intellij (over a windows machine) you need to:
Install Microsoft Visual C++ Redistributable for Visual Studio
Download and extract the OR-Tools library for Java
In intellij, add jar dependency to the 2 jars under the lib folder of the extracted files (each of the 2 jars separately, do not add to lib folder itself. This is why).
Add the lib library path to VM options. In Intellij edit your run-configuration and add to vm options: -Djava.library.path=<path to the lib folder that hold the jars>
Load the jni library statically by adding the below code to your class (as mentioned here.)
static {
System.loadLibrary("jniortools");
}

UnsatisfiedLinkError Java with Rxtx library

I am trying to communicate to Arduino with Java, so I'm using the rxtx library. I've downloaded the library and placed the respective files in my java project's folder. I put the rxtxxjar in a lib folder in the java project's folder, and I left the serial.jnlib straight into the java project's folder. I've taken the SerialTest code off of the arduino website, and I've tried to run it but I keep getting the UnsatisfiedLinkError. I've researched this question, and I've seen people saying basically the following in different ways:
Go to Project -> properties -> Java build path ->Find your .jar. Click
on + to open the JAR's properties. Select Native library location and
edit it to point to RXTX's shared library (.DLL, .so, .dylib).
However, I have no idea how to do the pointing to the shared library, especially since I don't see any .dll, .so, or .dylib file, and I cannot use the .jnlib because it is greyed out. Also on a smaller note, by my .jar is that just the project? I work in Eclipse Java EE.
You can use
System.load("Absolute path to your jni library");
This works fine on my project.

Native library in android project not found (UnsatisfiedLinkError)

I have an android project and I added an external .jar file which contains several .class files and in addition some .so files.
When I try to use some methods which are provided by the .class files I get a UnsatisfiedLinkError-Exception which says that the implementation for those methods couldn't be found.
Obviously the problem is that the .so libraries which contain the implementation were not correctly loaded/cannot be found.
What do I have to do that the native libraries in the external .jar file can be found from the runtime?
More details:
I'm using AndroidStudio and the app is tested on the emulator with the device "Nexus 5 API 23 x86". The .so files support x86 too.
I copied the .jar file into the /app/libs folder. Then I right-clicked the file in the IDE and selected "Add as library".
As you see that crash is saying that it could not load native library. But why?
First of all I checked my structure, If native library .so files located correctly.
Seems everything was okay except this crazy error.
Then after some research, I find out that some of android devices has 64-bit processors.
This devices generates and check arm64 folder to load native library.
That was the problem. Because my project does not have arm64 folder.
Here is the solution;
defaultConfig{
ndk {
abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
}
}

Android Development via Java Eclipse: I am Exporting But It Is Not Exporting As .apk file

I am fairly new to Java android development and have exported my apps in the past as .apk files however today, it is exporting it as an unknown file to me. I really need the .apk
file. Can anyone help?
Thanks,
Right click your project, click Android Tools > Export Signed Application Package.
usually you can just add .apk to the file name and i will work fine
If your project builds than you just have to go into the bin folder of your project (via Explorer) and grap the .apk. (Of course this is not officially signed but good for testing)

Categories