将 Android 的 OpenCV 库导入 Eclipse 后出错
Error after importing OpenCV Library for Android into Eclipse
在 Eclipse 中导入 OpenCV 库后,我遇到了一个错误。我想我做了我应该做的,但也许我错过了什么。样本没有错误,但我的应用程序有错误,OpenCV Library-2.4.10 也有错误。
这是我的输出:
问题
Description Resource Path Location Type
make: *** Android NDK: Aborting... . Stop. Cammect line 209, external location: /home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk C/C++ Problem
make: *** Android NDK: Aborting... . Stop. OpenCV Library - 2.4.10 line 209, external location: /home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk C/C++ Problem
make: *** Android NDK: Aborting... . Stop. src line 209, external location: /home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk C/C++ Problem
make: *** No rule to make target `clean'. Stop. RemoteSystemsTempFiles C/C++ Problem
控制台:
22:21:19 **** Clean-only build of configuration Default for project OpenCV Library - 2.4.10 ****
/home/crash-id/Development/SDK/android-ndk-r10c/ndk-build clean
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk
/home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk:209: *** Android NDK: Aborting... . Stop.
22:21:19 Build Finished (took 132ms)
错误日志:
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_31
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
org.eclipse.jdt.core
Error
Sun Feb 08 22:21:23 EET 2015
Invalid ZIP archive: /home/crash-id/Development/SDK/adt-bundle-linux-x86_64-20140702/sdk/extras/android/support/v7/appcompat/bin/android-support-v7-appcompat.jar
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_31
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
org.eclipse.cdt.core
Error
Sun Feb 08 21:45:35 EET 2015
Error: Cannot run program "/ndk-build": Unknown reason
java.io.IOException: Cannot run program "/ndk-build": Unknown reason
at org.eclipse.cdt.utils.spawner.Spawner.exec(Spawner.java:349)
at org.eclipse.cdt.utils.spawner.Spawner.<init>(Spawner.java:91)
at org.eclipse.cdt.utils.spawner.ProcessFactory.exec(ProcessFactory.java:91)
at org.eclipse.cdt.core.CommandLauncher.execute(CommandLauncher.java:194)
at org.eclipse.cdt.internal.core.BuildRunnerHelper.build(BuildRunnerHelper.java:263)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeExternalBuild(ExternalBuildRunner.java:128)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeBuild(ExternalBuildRunner.java:72)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:753)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:510)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:459)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_31
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
org.eclipse.cdt.core
Error
Sun Feb 08 21:45:35 EET 2015
Error: Cannot run program "/ndk-build": Unknown reason
java.io.IOException: Cannot run program "/ndk-build": Unknown reason
at org.eclipse.cdt.utils.spawner.Spawner.exec(Spawner.java:349)
at org.eclipse.cdt.utils.spawner.Spawner.<init>(Spawner.java:91)
at org.eclipse.cdt.utils.spawner.ProcessFactory.exec(ProcessFactory.java:91)
at org.eclipse.cdt.core.CommandLauncher.execute(CommandLauncher.java:194)
at org.eclipse.cdt.internal.core.BuildRunnerHelper.build(BuildRunnerHelper.java:263)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeExternalBuild(ExternalBuildRunner.java:128)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeBuild(ExternalBuildRunner.java:72)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:753)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:510)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:459)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
从您的错误日志来看,您的 Android NDK 的路径似乎是错误的。您可以通过在 Eclipse 中指定 Android NDK ndk-build
的完整路径来更正此问题。
首先,创建一个Build Variable
。在 Eclipse 中,转到 Window
-> Preferences
-> C/C++
-> Build
-> Build Variables
。添加一个引用 Android NDK ndk-build
文件的完整路径的新变量(您可以将其命名为 NDK_ROOT
或任何您想要的名称)。
然后,单击 Apply
并单击 Environment
(Preferences
-> C/C++
-> Build
-> Environment
) 和添加刚刚创建的变量。单击 Apply
和 OK
。
之后,右键单击您的 Open-CV-Library,然后 select Properties
。导航到 C/C++ Build
-> Environment
并在那里添加新创建的变量。单击 Apply
和 OK
。
应该可以。我就是这样修的。
希望对您有所帮助。
编辑
另一个修复可能是使用版本 2.4.9 而不是版本 2.4.10,因为 OpenCV 网站上的当前说明适用于版本 2.4.9。
我从 2.4.10 改为 OpenCV Library 2.4.9 后,错误消失了。在我使用 .mk 文件创建 jni 文件夹后,我的应用程序的错误消失了。
在 Eclipse 中导入 OpenCV 库后,我遇到了一个错误。我想我做了我应该做的,但也许我错过了什么。样本没有错误,但我的应用程序有错误,OpenCV Library-2.4.10 也有错误。
这是我的输出:
问题
Description Resource Path Location Type
make: *** Android NDK: Aborting... . Stop. Cammect line 209, external location: /home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk C/C++ Problem
make: *** Android NDK: Aborting... . Stop. OpenCV Library - 2.4.10 line 209, external location: /home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk C/C++ Problem
make: *** Android NDK: Aborting... . Stop. src line 209, external location: /home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk C/C++ Problem
make: *** No rule to make target `clean'. Stop. RemoteSystemsTempFiles C/C++ Problem
控制台:
22:21:19 **** Clean-only build of configuration Default for project OpenCV Library - 2.4.10 ****
/home/crash-id/Development/SDK/android-ndk-r10c/ndk-build clean
Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk
/home/crash-id/Development/SDK/android-ndk-r10c/build/core/add-application.mk:209: *** Android NDK: Aborting... . Stop.
22:21:19 Build Finished (took 132ms)
错误日志:
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_31
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
org.eclipse.jdt.core
Error
Sun Feb 08 22:21:23 EET 2015
Invalid ZIP archive: /home/crash-id/Development/SDK/adt-bundle-linux-x86_64-20140702/sdk/extras/android/support/v7/appcompat/bin/android-support-v7-appcompat.jar
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_31
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
org.eclipse.cdt.core
Error
Sun Feb 08 21:45:35 EET 2015
Error: Cannot run program "/ndk-build": Unknown reason
java.io.IOException: Cannot run program "/ndk-build": Unknown reason
at org.eclipse.cdt.utils.spawner.Spawner.exec(Spawner.java:349)
at org.eclipse.cdt.utils.spawner.Spawner.<init>(Spawner.java:91)
at org.eclipse.cdt.utils.spawner.ProcessFactory.exec(ProcessFactory.java:91)
at org.eclipse.cdt.core.CommandLauncher.execute(CommandLauncher.java:194)
at org.eclipse.cdt.internal.core.BuildRunnerHelper.build(BuildRunnerHelper.java:263)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeExternalBuild(ExternalBuildRunner.java:128)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeBuild(ExternalBuildRunner.java:72)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:753)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:510)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:459)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
eclipse.buildId=4.4.1.M20140925-0400
java.version=1.8.0_31
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product
org.eclipse.cdt.core
Error
Sun Feb 08 21:45:35 EET 2015
Error: Cannot run program "/ndk-build": Unknown reason
java.io.IOException: Cannot run program "/ndk-build": Unknown reason
at org.eclipse.cdt.utils.spawner.Spawner.exec(Spawner.java:349)
at org.eclipse.cdt.utils.spawner.Spawner.<init>(Spawner.java:91)
at org.eclipse.cdt.utils.spawner.ProcessFactory.exec(ProcessFactory.java:91)
at org.eclipse.cdt.core.CommandLauncher.execute(CommandLauncher.java:194)
at org.eclipse.cdt.internal.core.BuildRunnerHelper.build(BuildRunnerHelper.java:263)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeExternalBuild(ExternalBuildRunner.java:128)
at org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner.invokeBuild(ExternalBuildRunner.java:72)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:753)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:510)
at org.eclipse.cdt.managedbuilder.internal.core.CommonBuilder.build(CommonBuilder.java:459)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:734)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager.run(BuildManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
从您的错误日志来看,您的 Android NDK 的路径似乎是错误的。您可以通过在 Eclipse 中指定 Android NDK ndk-build
的完整路径来更正此问题。
首先,创建一个Build Variable
。在 Eclipse 中,转到 Window
-> Preferences
-> C/C++
-> Build
-> Build Variables
。添加一个引用 Android NDK ndk-build
文件的完整路径的新变量(您可以将其命名为 NDK_ROOT
或任何您想要的名称)。
然后,单击 Apply
并单击 Environment
(Preferences
-> C/C++
-> Build
-> Environment
) 和添加刚刚创建的变量。单击 Apply
和 OK
。
之后,右键单击您的 Open-CV-Library,然后 select Properties
。导航到 C/C++ Build
-> Environment
并在那里添加新创建的变量。单击 Apply
和 OK
。
应该可以。我就是这样修的。
希望对您有所帮助。
编辑
另一个修复可能是使用版本 2.4.9 而不是版本 2.4.10,因为 OpenCV 网站上的当前说明适用于版本 2.4.9。
我从 2.4.10 改为 OpenCV Library 2.4.9 后,错误消失了。在我使用 .mk 文件创建 jni 文件夹后,我的应用程序的错误消失了。