Search code examples
javaandroidopencvimportbuildpath

Android opencv library reference is not working correctly


At first i would like to say that I am working for 5 hours to solve that problem and I tried really hard to describe it well, if something is not clear please tell me.

I have downloaded Tegra Developer Pack imported Open CV 2.4.3 library project and sample projects which work great for on my device Samsung Galaxy Note 2. I have tried many ways to make my opencv project work but they do not.

I have created project and added Android library reference in the project properties. Exacly as every sample project has it done. But "they" get green tick but I at first get the green tick but when I enter properties again red cross appears :

My project: enter image description here

Sample project:

enter image description here

In the end my project is full of errors(cannot import class etc.), sample projects are clean.

I have also tried to import OpenCv by adding its jar file to build path like this.

enter image description here

Then import problems in java files are gone but stil any xml containing OpenCV parts will not work.

Example:


Result:

enter image description here

The following classes could not be instantiated:
- org.opencv.android.JavaCameraView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
Tip: Use View.isInEditMode() in your custom views to skip code when shown in Eclipse

java.lang.ClassNotFoundException: org.opencv.R$styleable
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

....

The weird thing is when i click Open Class in error listing above it will open the right JavaCameraView source code


Solution

  • Ok I finally found out how to fix it.

    If you want to work with tegra developer pack make your workspace directory the directory of samples: Tegra\OpenCV-2.4.3.2-android-sdk-tadp\samples

    Or probably always copy imported projects, do not make reference to them.