0

I am currently trying to run the OpenCV samples for Android found here (I have tried with more recent versions, but I followed the suggestion from this question's answer) and am running into the error

Failed to create BuildConfig class

as well as

OpenCV-2.3.1] Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project

For the first error; I still cannot find a solution; I've tried replacing the latest OpenCV with that suggested (2.3.1) in the answer mentioned above instead of 2.4.2 (also tried 2.4.0). The answer advised to use the exact version 2.3.1, but so far it doesn't seem to do the trick.

For the second error, I tried following the suggestion here by adjusting the JDK compilance version but also that problem hasn't been solved.

Here's a snapshot of some of the errors:

enter image description here

Using:
- Eclipse Indigo
- Windows7- 64bit

I couldn't find much help online for the problem, I've been looking out for a way around it for some time now. I've followed the exact steps in this tutorial (done downloading the ndk and reached up to this point) where errors were indeed anticipated and seemingly easy to eliminate in the tutorial, but they're not as those in question.

Thank you in advance.

Community
  • 1
  • 1
Noha Kareem
  • 1,748
  • 1
  • 22
  • 32

1 Answers1

0

Below are three solutions that, combined, seemed to do the trick (to eliminate the errors). The samples work fine now (tested on an Android 2.2 phone):

  • I've noticed a line in this tutorial (seems as another version of that linked in the question) stating

    If you have created workspace in the package directory, then just click Browse... button and instantly close directory choosing dialog with OK button!

    This seems as a must; placing the package directory in the eclipse workspace that is. I've seen this recommendation also as an answer to this question.

  • I've also installed Android API 11 from the SDK manager (earlier I've only installed the API levels 8 and 16) which was the recommended minimum level in the tutorial. The mere installation was a step I've made as suggested in an answer to this question where the question referred to an error similar to one of those I've found trying to build the samples. I am unsure however whether this was one of the reasons why errors faded, since I did this step before moving the opencv library to the eclipse workspace with no testing of the sample projects in between as far as I recall.

    I've tested the samples on an Android2.2 (API level 8) phone however(not emulator. I'm not sure if that's possible since in this tutorial it mentioned that only sample projects Tutorial 0 and Tutorial 1 would work on an emulator, from my experience so far neither have), which is also the minimum API level (8) currently set in my opencv samples' manifest files, and it worked.

  • Lastly, I had this error remaining;

    Cannot run program "\ndk-build": Launching failed PROJECT NAME C/C++ Problem

    which was easily resolved but accessing the project properties (per needed project), heading to C/C++ Build > Environment > Add (seen to the right of the table heading Environment variables to set > fill in the Name with NDKROOT and provide your ndk path in the Value. For the reference from which I've found this advice (and where there exist other options) please check this Q&A.

That was my experience for letting the OpenCV samples for Android work.

Community
  • 1
  • 1
Noha Kareem
  • 1,748
  • 1
  • 22
  • 32