7

I have made modifications to several example OpenCV projects within Android, however I am having some issues with using OpenCV successfully in a new Android project.

The documentation on using OpenCV with Android says to complete the following steps to add OpenCV to an Android project -

  • ensure the Android project is in the same workspace as OpenCV
  • add a reference to the OpenCV project by going to Properties > Android > Library > Add and choosing the OpenCV Library project

I have followed both of these steps, however when I compile my application I receive the console error -

Could not find OpenCV-2.3.1.apk!

Eilidh
  • 1,354
  • 5
  • 21
  • 43
  • I don't think you want the apk file. You probably want a tar/zip file that Eclipse can deal with once expanded. [This link for openCV explains more](http://opencv.itseez.com/doc/tutorials/introduction/android_binary_package/android_binary_package.html) – Martin Mar 26 '12 at 12:42
  • That is the same link I provided in my original question. As I said in my question, I have followed all the steps provided in that documentation – Eilidh Mar 26 '12 at 12:47

3 Answers3

17

When creating a new Android project, the only thing you need to do is

  • add a reference to the OpenCV project by going to Properties > Android > Library > Add and choosing the OpenCV Library project

You should not then explicitly add OpenCV Library project into your new Android project's build path:

  • add another reference to the OpenCV project by going to Properties > Java Build Path > Projects > add...

If you do latter step, you will get the exact error Could not find OpenCV-2.3.1.apk! described in the question.

Check out the New Android project's build path and remove OpenCV project if it exists, then give it another try and see if this helps.

yorkw
  • 40,926
  • 10
  • 117
  • 130
  • Thank you! That fixed the problem :) Oddly enough when I opened the project up again, the project was compiling and running perfectly in spite of the 'Could not find OpenCV-2.3.1.apk!' error. I removed the reference to OpenCV in the project's build path, and now no longer receive the error :) (I think possibly something may have been up with my OpenCV install which caused an unrelated error which was the real source of the problem, as it was automatically installed / updated again when I installed SimpleCV yesterday) Thanks very much for your help :) – Eilidh Apr 01 '12 at 10:59
  • @ShimmerGeek, Glad to hear it helps:) – yorkw Apr 01 '12 at 11:01
  • Could you please add a link to an Eclipse project already created? I would help us a lot – Duna Mar 27 '13 at 15:44
2

When you add OpenCV from Properties->Android->libarary->Add you need to leave "Is Library" checkbox unchecked. Go to Project->Properties->Android and uncheck "Is Library" and then try again. It should solve your issue (it did for me) but if it doesn't please take a look at the answers of this question as other people have found some other things to be helpful as well.

Community
  • 1
  • 1
binW
  • 13,220
  • 11
  • 56
  • 69
  • Thanks, it was actually unchecked at first - I tried checking it to see if that solved the issue but it didn't and gave me a different error though, so I unchecked it once again :) – Eilidh Apr 01 '12 at 10:47
0

I had this problem when I pulled in the jni_part.cpp file from a sample project. I forgot to change the names of the functions to fit the package name of the class I was using them from:

JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial3_Sample3Native_FindFeatures ->

JNIEXPORT void JNICALL Java_<CLASSNAME_WITH_UNDERSCORES_INSTEAD_OF_DOTS>_<CLASS_NAME>_<METHOD_NAME>

Hope this helps someone.

alistair
  • 1,164
  • 10
  • 27