I am looking to use an android class on a regular non-android java project. Specifically I want to use FaceDetector from android.media
I know that there are OpenCV and other libraries I can use to detect a face in an image but I am looking to use androids library. Is there a way to link androids library to a java project?
Thanks
Go to build path of your java project
Add a new external jar
Browse to the location of your android platform installation
(usually C:\Program Files (x86)\Android)
Under android-sdk\platforms\android-x (where x is the version of android you have) select the android.jar file to add to the project.
Now you have the android library under the referenced libraries, and you can use whatever android classes you want in your java project.
Another way of doing that is to use the android source, get only the java files you need from the android library and put them into your java project. The good thing when you do it this way is that you can modify the code and make it more compatible with your java work.
The android library might contain some calls to the system API's. Look for them before including the library with the above mentioned steps. I would recommend you to look into the documentation of the android library and look for the hooks where it calls android system APIs.Modify the source to use your webcam's API and then include it as a library
Related
I have to use some native library in my android app.
I didn't build this library. It is open source available library. I am using Android Studio 2.1.
So I have two things:
1. Source for Linux: gcc x86/x64 (.a, .h) files
2. Wrapper for Linux: one library.so file and one library.jar file
What I want to achieve is to use library.so file and library.jar file to consume the library in my Android app.
1) Is it possible?
2) If it is possible then how to do this?
3) If it is not possible then I have only option to do something with NDK?
4) If I have only option to use NDK then how to achieve my goal using NDK?
Note: I am new to Android and NDK I don't know anything please correct me and redirect me to a right path. Please use basic terms so that I can understand easily. Thank you :)
I am very new to JAVA/ Android world. I come from C background. The AndroidStudio / Gradle stuff is a bit overwhelming for me.
I am looking to create a library using AndroidStudio. But when I click on "Start a new Android Studio Project" it asks me for Application name and then for activity et al. This is where it gets confusing for me. Why would these details be required to create a library module? Am I missing something here?
I know that there is a File - > New Module Menu and all that stuff, but that comes later once I have set the applicaton details. But here, I dont want to create any application, just the lib (similar to a shared library I would create in C using Makefiles/autotools).
Also, A library in Android world is basically a jar file (like we have *.so in C), right?
1) While Android tools does accept/use Java JAR files, JARs don't contain Android specific stuff like resources (bitmaps,xml) as well as the necessary meta-data to properly merge all of that into a client project. So with the 'new' Gradle based tools we now have AAR format http://tools.android.com/tech-docs/new-build-system/aar-format and the toolchain knows how to handle them.
2) Which brings you to Create aar file in Android Studio
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.
I'm currently trying to build an android application using the Android 4.1.2 Java libraries.
Unfortunately, I want to use a newer version of the org.json package, which appears in that library.
Am I able to tell Eclipse not to use the org.json package in the Android 4.1.2 Jar?
It sounds like you are encountering a Java package name collision. Unfortunately as the code in Android comes pre-packaged, your best bet is to rename the newer json package and use that to avoid using the prebuilt one.
If same class with package is available through two different JARs in the buildpath, you can't do that properly.
One step you may try is to put new jar on top in the order using Order and Export tab of Eclipse build path UI.
The best way is to update you Android Lib folder in the file system and replace the older jar with the newer JAR.
Please note: There might be an compatibility issue when you attempt to use a different JAR than the one supplied with the package.
I want to include android libraries in my java project. Actually, I need to run android code in java environment , obviously, this android code would not contain any GUI based action, it will simply use android's predefined libraries ... please suggest to me how android's libraries can be included in java project.
Thanks in Advance !
Find the JAR file containing the libraries you want to use, and add them to the Java project's build classpath.
However this may not work, depending on the Android classes you want to use. Some Android classes will have dependencies on the Android platform which will make it unlikely they will work ... or even load ... on a regular Java platform.
If you want to reference a java jar as reference:
Add that to libs folder in you project
Right click on project -> Properties - > java Build path -> libraries -> add jars
If you want reference a android library project then
Right click on project -> Properties - > Android - > Add (in lower part of window)
You can use android apis in android library project
Setting up library project refer.
You can find the difference between jar library and android library here