Search Unity

Error when combining UnityPlayerActivity with opencv

Discussion in 'Android' started by kyewong, Jun 28, 2016.

  1. kyewong

    kyewong

    Joined:
    Sep 11, 2014
    Posts:
    22
    Hi all,

    I am planning to combine unity java plugin with opencv on android, to use the android native camera instead of using Unity webcamtexture. When I tried to implement CvCameraViewListener2 based on UnityPlayerActivity (the code is like: public class MainActivity extends UnityPlayerActivity implements CvCameraViewListener2), the error:
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.kw.testopencv/com.kw.testopencv.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.kw.testopencv.MainActivity" on path: DexPathList[[zip file "/data/app/com.kw.testopencv-2/base.apk"],nativeLibraryDirectories=[/data/app/com.kw.testopencv-2/lib/arm, /vendor/lib, /system/lib]]

    always occurs, and the app crashes when started.

    However if I only use UnityPlayerActivity to extend MainActivity, without implementing CvCameraViewListener2, it works well.

    I exported the .jar file in Eclipse IDE and put it into the 'Assets\Plugins\Android' folder, together with the AndroidManifest.xml and 'res' folder following the official guide.

    I attached the MainActivity.java and AndroidManifest.xml.

    Could anyone tell me where is the problem please?
    Thank you!
     

    Attached Files:

  2. dole_doug

    dole_doug

    Joined:
    Aug 3, 2016
    Posts:
    1
    did you solve this problem?
    can you share it?

    I'm getting the same error message and I'm out of ideas
     
  3. kyewong

    kyewong

    Joined:
    Sep 11, 2014
    Posts:
    22
    Sorry but i failed to make it work. Instead I used the Android Camera class inside the inherited UnityPlayerActivity class to get the camera byte[] data and convert it to opencv mat myself.