OpenCV C++ with Android - android

I have checked a lot of threads already but none of them seems to solve my problem. I'm working on a project regarding my study and want to use the OpenCV library with my Android app. Here is a list of the programs and tools I use:
Eclipse IDE for Java Developers (3.7.0)
Android SDK r16
OpenCV 2.3.1
Android NDK r7b
I am following a tutorial, and everything works fine until the part where I need the NDK for using C++ OpenCV code. I can code and run Android apps and the "Tutorial 1" samples from the OpenCV 2.3.1 are working fine. However the "Tutorial 2" samples won't work. I tried following the steps in the C++ part of the tutorial.
When I try to run the NDK-build (tried both the command line and Eclipse part) I keep getting this error:
/usr/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [obj/local/armeabi/objs/opencv/cvjni.o] Error 1
Does anyone has a solution for my problem? Thanks in advance

in bash script unexpected "syntax error: unexpected end of file" on if statement
Make sure your shell scripts use Unix-style line endings

Related

Compiling ffmpeg for android using cygwin-x86

I'd like to test ijkplayer (android) project.
During compiling ffmpeg libs (./compile-ffmpeg.sh) usin Cygwin in WIN7 environment I faced the following error message:
"build on CYGWIN_NT-6.1 x86_64
Host system 'cygwin-x86' is not supported by the source NDK!
Try --system= with one of: windows-x86_64"
The suggested 'system' command doesn't solve the problem.
Axtually I use android-ndk-r10c
If I try the same process using MINGW32 I get a lot of syntax error.
Please help!

Make.exe Access denied

I am facing following two problems
1.Access is denied during ndk-build.
G:/AndroidApp/NativeCodes -> It has my native codes(c++) codes,when i try
to build this,it is compiling the source files and creating the lib but at last
i am getting *make.exe: *** Access is denied.. Stop.*
2.And when i launch eclipse i am getting following two error in
a) Android NDK: WARNING: There are no modules to build in this project!
b) G:\AdroidApp\Meddiff: **Permission denied**
NDK which i am using is, r10c 32 bit.
Problem solved by disabling antivirus.
I found an answer which worked for me on https://stackoverflow.com/a/17155381/1065835
A C file was opened in Eclipse and Beyond Compare. After I'd closed the latter, everything was build well.
My OS was Windows 8 (64-bit)

Android ndk-build error make.exe: *** create_child_process: DuplicateHandle(In) failed (e=6)

I'm relatively new to Android and I have a problem using the ndk-build command.
I use the NDK r9d under Windows 7 64bits.
When I run my build system which creates my Android project (makefiles etc...) and then creates a process running ndk-build.cmd (I checked that it is call in the Android project) I get the error:
make.exe: *** create_child_process: DuplicateHandle(In) failed (e=6)
But when I run ndk-build.cmd "manually" in the windows command console in the same Android project created by my build system (or any Android project) everything is working.
I did find some related questions like here:
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014825836
https://cygwin.com/ml/cygwin/2004-09/msg01506.html
But all I found says either that it's a problem of make version which is not (I think) since ndk-build works fine when I use it "manually" or it says that it is related to stdin handling and again I don't think that the issue here. Plus all the anwsers that I found was related to a similar error but not exactly the same:
process_easy: DuplicateHandle(In) failed (e=6)
Maybe someone knows the meaning of my error message. I don't think that's specific to Android ndk-build but maybe.
Thank you for reading (and sorry for any english mistakes, I am french and not fluent in english)
Finaly, I found a solution to my problem here:
http://www.zeusedit.com/zforum/viewtopic.php?t=174
I am not sure about what the problem was but according to this link, it was related to the make environment and the handles.
The solution : Instead of using the createProcess function (from Windows) directly to call ndk-build.cmd, I created a batch file containing:
start ndk-build.cmd
And I called this batch (.bat) via the createProcess function.
I let you see the link for more details.

Errors running builder 'CDT Builder' when trying to build OpenCV for android samples

Hello guys I'm trying to learn about openCV in android
I've already following the instruction given here
but when I'm trying to compile I'm only getting
01:50:14 ** Auto Build of configuration Default for project
org.opencv.samples.fd.FdActivity **
"C:\Android\android-ndk-r8\ndk-build.cmd" Install:
libdetection_based_tracker.so =>
libs/armeabi-v7a/libdetection_based_tracker.so
01:50:14 Build Finished (took 184ms)
in the console
and I'm also get an error
Errors occurred during the build. Errors running builder 'CDT Builder'
on project 'org.opencv.samples.fd.FdActivity'. Internal error building
project org.opencv.samples.fd.FdActivity configuration Default
java.lang.NullPointerException Internal error building project
org.opencv.samples.fd.FdActivity configuration Default
java.lang.NullPointerException
anyone ever encountered this problem before?
please help me to solve this problem
thank you
try
Project Properties>C/C++ Build>Tool Chain Editor
Current toolchain: Android GCC
Current builder: Android Builder
Project Properties>C/C++ Build
(uncheck) use default build command
Build command: ndk-build
(uncheck) generate Makefiles automatically
You may have renamed the project, and the eclipse forgot to rename the "Refresh Policy".
Just update "Project properties -> C/C++ Build -> Refresh Policy" manually solved my problem.
BTW, ADT has some very bad error descriptions as of in this case.
I might have the same problem,
try ndk-build -B which rebuild all the things, see whether you still got error,
if no error remain, there is no problem with your ndk-build. try to run your android apps without CDT installed, if this works, at least we could use comand line to build the c++ part of code.
but CDT is still not working well, after I install the CDT according to the opencv doc, I got lots of errors, add the cygwin and gcc things to the path would solved most of it. But the last things every strange is, I got an error here.
in the face detection sample, .cpp part
catch(cv::Exception e)
{
LOGD("nativeCreateObject catched cv::Exception: %s", e.what());
it always says symbol "e" can not be resolved.
but no error when I include the opencv things.
even when I try to put cv::Exception e outside of the catch()
These works for me:
Build command: ndk-build
(uncheck) generate Makefiles automatically

ndk-gdb can't find source line numbers

I'm using the ndk-gdb to debug some native code on the Android platform. However, the debugger seems to be unable to find source line numbers and source files. I get warnings and errors like this:
warning: shared library handler failed to enable breakpoint
0xaff0c184 in ?? ()
and
Program received signal SIGSEGV, Segmentation fault.
0x80e030a8 in ?? ()
That's not very useful at all... It seems to me that the problem must be in the file and line-number look-up, but as I am quite new to native programming for Android, I'm kinda stuck here. So can anyone tell me how to fix this problem? Any help would be very much appreciated!
Edit 1:
I'm using the NDK r7b on Windows and call the ndk-build script with the following options:
$NDK/ndk-build NDK_DEBUG=1 APP_OPTIM=debug V=1
The APP_OPTIM=debug setting is a modification to the ndk-build script that should disable the stripping of debug symbols as per these instructions.
Edit 2:
I have not solved this problem, but worked around it by switching to using the NDK on Ubuntu linux. It kinda feels like surrendering to the NDK but time and again the linux-roots of the Android platform made developing native code for it on Windows feel unnatural and clumsy.
Kind regards,
Jonas

Categories

Resources