Target Application: Development of an Unity application for android device.The Unity application will use OpenCV for various image processing functions.
Approach Planned:
Develop an OpenCV for android application in Android Studio. This will have a bridge class for sharing data with Unity.
Export the android studio project into jar
Use the jar and other assets in Unity as a Plugin
Access the required functions for image processing using the bridge class in android using the Android Java support classes in Unity.
Build the unity application for Android Platform
Experiments Done:
Already did a set up for OpenCV for android in Android Studio.
Tested sample applications on device by generating apk.
Tested the plugin concepts in unity using DLLs for a windows based application. Dll concepts working fine for Unity.
Final Experiment--
4. Used the classes.jar generated in the build\intermediates\exploded-aar... as a plugin in Unity. It generates an apk from the unity build. The apk gets installed on a device but fails to open.(Can't see it in the apps menu)
Used this .jar approach based on an answer in the following link How to export library to Jar in Android Studio?
Problems:
- Most of the android plugin tutorials use Eclispe and have the export to jar function. This jar file can be used as a plugin in unity.
Queries:
I found about the jar task which could be included in the gradle script. But I am not sure how to use it ? There seems to be a lot of version for the jar task creation in Android studio. How to achieve for a project using opencv in android?
I am also confused whether .jar or .aar will solve my purpose?
Should I try any other approach like the android library for achieving the android, Opencv and unity integration.
My take on Solutions:
Generating the appropriate jar in Android Studio will solve the issues.
Else go back developing the opencv for android in eclipse
Useful Links
Can Android Studio be used to create Unity-plugin compatible JARs out of Library projects?
The following project approach is almost the same which I want to acheive https://github.com/thorikawa/unity-opencv-android
Any help on this will be appreciated.
Update 24th Feb 2015
With the help of this link Can Android Studio be used to create Unity-plugin compatible JARs out of Library projects?
I am able to integrate Unity and Android.
The android studio project now contains two classes an activity class and a normal java class containing various getter functions.
I am able to call any functions of the normal java class from unity.
But unable to start the activity class from unity.
My Thoughts
I guess unity generates its own manifest file while doing a build for android in unity.
Changing the android studio manifest file accordingly might solve the issues.
Queries
How to start an activity inside the android library from Unity?
How is the android studio generated manifest file provided in unity so that unity merges it with its own generated manifest without any conflicts?
Things Tried
While building in unity, if no android studio generated manifest file is provided, the app functions properly and communicates with the simple java class with getter functions.The values can be obtained in Unity.
If the default manifest file is provided along with the classes.jar the app gets installed but crashes on opening. Even the app name is changed to the one provided by the android studio manifest file.
If any one could help me with this I ll be grateful. Besides I think if I solve this step integrating opencv for android won't be very tough.
Best regards, Swaroop