0

我目前正在尝试运行此处找到的适用于 Android 的 OpenCV 示例(我已尝试使用更新的版本,但我遵循了问题答案中的建议)并且遇到了错误

未能创建 BuildConfig 类

OpenCV-2.3.1] Android 需要编译器合规级别 5.0 或 6.0。而是找到了“1.7”。请使用 Android 工具 > 修复项目

对于第一个错误;我仍然找不到解决方案;我尝试用上面提到的答案中建议的(2.3.1)而不是 2.4.2(也尝试过 2.4.0)替换最新的 OpenCV。答案建议使用确切的版本 2.3.1,但到目前为止它似乎并没有起到作用。

对于第二个错误,我尝试按照此处的建议调整JDK编译版本,但该问题仍未解决。

以下是一些错误的快照:

在此处输入图像描述

使用:
- Eclipse Indigo
- Windows7- 64bit

我在网上找不到太多关于这个问题的帮助,我一直在寻找解决它一段时间的方法。我已经按照本教程中的确切步骤进行操作(完成下载 ndk 并达到这一点),其中确实可以预料到错误,并且在教程中似乎很容易消除,但它们并不像那些有问题的那样。

先感谢您。

4

1 回答 1

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.

于 2012-09-24T14:11:22.120 回答