I managed to create a java package from a Matlab function (for image processing) using deploytool. I tested it in Eclipse and it runs perfectly. The problem is that I want to use this Matlab function for an Android Studio project and I can´t find any way to make it work.
As you may know, when you use Matlab´s deploytool for java packages it generates three folders: "for_redistribution" which contains an .exe file (MyAppInstaller_web.exe), "for_redistribution_files_only" that contains the .jar and documentation, and "for_testing" which contains pretty much the same, the .jar file, documentation and java classes
My question is: is it possible to use this in an Android App? And if so, how? And are there any other options (other than using openCV instead of a Matlab function) to make it work?
Thank you in advance
Java components that are generated from MATLAB code using deploytool (or using other functionality from MATLAB deployment products such as MATLAB Compiler, MATLAB Builder etc.) depend on the MATLAB Compiler Runtime (MCR).
The MCR has much too large a footprint to run on an Android device, and it's really not possible to deploy MATLAB Code to Android in this way.
You have two main options:
Use the add-on product MATLAB Coder to convert your MATLAB code to C. This C code does not (unlike the deployment products) depend on the MCR, and be compiled and incorporated into your Android app like other C code.
Deploy your java component as a web service, and have your Android app communicate with it remotely.
Related
Is it possible to write code for native libraries you do not have the source code for in your own android app?
For example - RarLab's android app comes with a native library librarlab_rar.so for at least 4 different platforms.
Assuming that I'm doing this for experimental and copyright isn't an issue and I don't plan to distribute the app externally, is it possible to compile a Java/Kotlin android-based app with only including the native binary in android development tools such as Android Studio or Eclipse?
You would need to disassemble the binary .so file and work out the API yourself. This process is called reverse engineering.
See: How do I reverse engineer .so files found in android APKs? for ideas on how to accomplish the task.
Once you've figured out how to call into the .so file, you can then write your own version of the API which you can then call from Java/Kotlin.
Any lib….so file that you put under jniLibs/$(ABI) folder in your app will automatically get packed to APK and unpacked to the device (provided the ABI matches). You may need to write your own Java wrapper for the libraries, or to reuse the Java classes that you need from the same app.
I need to call a relatively simple piece of python code (no dependencies) from my java-project for android. I have heard that it is possible to use python via Kivy. Would that be possible?
Kivy cannot be easily integrated in an existing Java app, Kivy (the android part) have already a integrated Java application. Python is the main part, and you can execute Java code from Python using Pyjnius. Or write direct Java code.
You want the inverse, which is not something we are targeting.
I suggest you to check android-python27 project instead.
I am trying to call up a user defined matlab function(.m file) from java android application which is developed in Eclipse using matlabcontrol.jar.
Actually, It works well when I use it in the java project.
But I wonder is it possible to use it when I develop android application.
The problem is When I use matlabcontrol.jar for java project, it pops up and runs matlab application(like R2009b matlab) automatically, even though I don't want to use it. then run and print result on the matlab console also.
Then, I think, if someone who didn't install matlab application in their computer or smartphone can't use application which is included matlab code.
So, I just want to run matlab code on java program(for android), not using matlab application. Give me option or alternative way to work out please?
Please help.
Thanks.
matlabcontrol just gives you a way to call a running copy of MATLAB from Java. If you have some MATLAB code that you want to run on an Android device, this is not going to work for you, as there is no version of MATLAB that will run on Android.
If you have MATLAB code that you'd like to run as part of an Android application, you have two real choices:
i) Use MATLAB Coder to convert the MATLAB algorithm to C code, that can be compiled, called from Java, and included in your app to run on the device. You'll need to ensure that your MATLAB algorithm falls within the subset of the MATLAB language that is supported by MATLAB Coder, but that usually isn't a big issue. MathWorks have a recorded webinar with a worked example of how to do this (it's Objective C on iPhone rather than Java on Android, but the principles are the same). It's called something like "MATLAB to iPhone made easy", if you want to look it up. Here's the link to it.
ii) Use either MATLAB Builder NE for .NET, or MATLAB Builder JA for Java to deploy your MATLAB algorithm as a web service, and have your Android application call that web service.
PS MATLAB Mobile is not a relevant option here - it is a tool for connecting to a MATLAB session on your machine or in the cloud, and interactively running MATLAB code. It does not give you a way of running MATLAB code on the device itself.
I an developing a Visual C++ 32-bit application in Visual Studio 2012.
One module in my application is developed in JAVA and is available as a jar library only. I need to call functions from the jar file in my Visual C++ Console application. These functions are implemented in JAVA. My Visual C++ application will call these functions. These functions will return some value (message) back to the Visual C++ application.
Most of the links/tutorials talk using JNI for accessing C/C++ code in a JAVA Application. How can I access functions/methods from the jar file to my Visual C++ console application?
any help/idea is appreciated
JNI is my answer too. Using JNI you can create a Java Virtual machine in your c++ program and invoke methods on Java classes.
Please check the following link for a small sample. I hope you can build upon this to meet your requirement.
http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html#wp9502
If i created a apk library with monodroid. Can i u use this just in Eclispe(Java) and do my rest code in Java ?
In short: no. A DLL compiled from a Mono for Android class library relies on the Mono runtime in order to run it, which wouldn't be present in a normal Java Android application. It is possible to go in the other direction though, and use Java libraries within a Mono for Android app. Xamarin has documentation of how their architecture available here.
That said, in some cases it is possible to access C# code from Java code when you're in the scope of a Mono for Android application. This question/answer has some good details about that.