2

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

Yoda
  • 17,363
  • 67
  • 204
  • 344

3 Answers3

3

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.

Yoda
  • 17,363
  • 67
  • 204
  • 344
  • 1
    in fact its not limited to Tegra pack i had the same problem with the ADT bundle and the per-built Opencv4Android and it worked like a charm – MolhamStein Mar 17 '14 at 12:23
2

Actually, the problem came from the fact that Eclipse referred to a library project via a relative path. You probably noticed about this from the sample project you show here (and it worked).

Technically, Eclipse calculates the relative path for us. Unfortunately, it just can't do that when our project and a referred library "are not in the same drive" (e.g. our project is in C: and a library is in D:).

Therefore, the actual requirement in Windows is that we put both project and referred library in the same drive in order that a relative path between the two exists.

[P.S. I know that this is an old post, but others may find my reply useful.]

pinyotae
  • 106
  • 4
0

Can you base 'your' project on 'theirs' project, instead of starting from scratch, since you're saying 'theirs' projects build fine?

Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
  • I have tried to copy the sample project but even a copy of it does not work. It lacks imports. Then the red cross also appears at the copy. – Yoda May 18 '13 at 19:09
  • I found out the answer there are only two things which differ original form copy, the name of the project and the directory... and the directory of samples and my workspace was different. – Yoda May 18 '13 at 19:26