opencv.hpp not found in NDK build on Windows - android

I am getting some issues here while I am trying to compile my code with Cgywin.
$ /cygdrive/c/native_work/android-ndk-r8b/ndk-build
Android NDK: WARNING: Unsupported source file extensions in jni/Android.mk for module main
Android NDK: NotePaperDetector.hpp
Install : libmain.so => libs/armeabi-v7a/libmain.so
so how I can compile the .hpp file ?
Now as #mah you said I have removed it from my Android.mk but now its showing some different error -
$ /cygdrive/c/native_work/android-ndk-r8b/ndk-build
Compile++ thumb : main <= NotePaperDetector.cpp
In file included from jni/NotePaperDetector.hpp:4:0,
from jni/NotePaperDetector.cpp:1:
jni/NoteLocation.hpp:4:30: fatal error: opencv2/opencv.hpp: No such file or directory
compilation terminated.
/cygdrive/c/native_work/android-ndk-r8b/build/core/build-binary.mk:255: recipe for target `obj/local/armeabi-v7a/objs/main/NotePaperDetector.o' failed
make: *** [obj/local/armeabi-v7a/objs/main/NotePaperDetector.o] Error 1

With the latest NDK releases you don't need Cygwin at all.
By the way a GNU/Linux platform is always the best for Android developers.

Related

Compiling stressapptest on NDK for Android

I am currently working on trying to compile the stressapptest (link: https://github.com/stressapptest/stressapptest) using the NDK environment, and for some reason, I'm having a hard time. These are the steps that I have taken:
Clone the repository onto my computer
Added a jni folder and moved all the files into it
Created an Application.mk file
Opened PowerShell from the location of my jni folder and execute ndk-build. This is the error I'm getting:
PS C:\Users\...\Desktop\stressapptest-master\stressapptest-master> ndk-build
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.
[arm64-v8a] Compile++ : stressapptest <= main.cc
In file included from jni/src/main.cc:17:
jni/src/sattypes.h:25:10: fatal error: 'algorithm' file not found
#include <algorithm>
^~~~~~~~~~~
1 error generated.
make: *** [obj/local/arm64-v8a/objs/stressapptest/src/main.o] Error 1
Is there anything else that I need in order to compile this to run on an Android system?
Set APP_STL to c++_shared in your Application.mk. ndk-build does not use any STL by default.

Android - file not found while building NDK library

I'm trying to build the SoundTouch library for Android, by following the guide provided within the source code:
Compiling
To compile the SoundTouch library source codes into an Android native
library, open Cygwin/bash shell, go to directory
"soundtouch/source/Android-lib/jni" and invoke the NDK compiler with
following command:
$NDK/ndk-build
This will build binaries for all the supported Android platforms
(arm-v5, arm-v7, X86, MIPS etc) of SoundTouch library, plus the JNI
wrapper interface as discussed below. The target binaries will be
built into the "libs" subdirectory. As long as all these .so binary
library versions are included in the APK Application delivery package,
the targer Android device can choose the correct library version to
use.
Notice that to allow Cygwin/bash to locate the NDK compile scripts,
you need to define the location of the NDK installation defined in
environment variable "NDK". That's easiest done by adding the NDK path
definition at end of your ~/.bash_profile file, for instance as
follows:
NDK=/cygdrive/d/Android/android-ndk-r6
to do this I go into Terminal in the SoundTouch/source/android-lib/jni directory and type the following commands:
export ANDROID_NDK=~/Android/Sdk/ndk-bundle
export NDK_ROOT=$ANDROID_NDK
export PATH=${PATH}:${ANDROID_NDK}
ndk-build
Then I get the following error:
[arm64-v8a] Compile++ : soundtouch <= soundtouch-jni.cpp
jni/soundtouch-jni.cpp:23:10: fatal error: '../source/SoundStretch/WavFile.h'
file not found
#include "../source/SoundStretch/WavFile.h"
^
1 error generated.
/home/daniele/Android/Sdk/ndk-bundle/build/core/build-binary.mk:499: recipe for target 'obj/local/arm64-v8a/objs/soundtouch/soundtouch-jni.o' failed
make: *** [obj/local/arm64-v8a/objs/soundtouch/soundtouch-jni.o] Error 1
If I go to that directory the file is there though. Here is a screenshot of the file with it's direcotry:

Android NDK: WARNING: Ignoring unknown import directory: jni/../../cocos2d

I am totally new to programming.
I am using windows 7 and eclipse.
I have searched all the place and i have tried all of the recommended solution and nothing works for me. Please let me know how to change them.
So please help me to understand what you are trying to say.
The cocos version i am using is 3.3 (cocos2d-x-3.3)
NDK is version r9D
Thank you.
I am not sure why CDT Build console is giving me these errors.
"
**** Build of configuration Release for project KIKILA ****
python C:/Users/SM/workspace/KIKILA/build_native.py -b release all
Android NDK: WARNING: APP_PLATFORM android-15 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
Android NDK: WARNING: Ignoring unknown import directory: jni/../../cocos2d
Android NDK: WARNING: Ignoring unknown import directory: jni/../../cocos2d/external
Android NDK: WARNING: Ignoring unknown import directory: jni/../../cocos2d/cocos
Android NDK: C:\apps\adt-bundle-windows-x86_64-20140702\cocos\cocos2d-x-3.3\external/flatbuffers/Android.mk: Cannot find module with tag 'external/jansson' in import path
jni/Android.mk:41: *** Android NDK: Aborting. . Stop.
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Traceback (most recent call last):
File "C:/Users/SM/workspace/KIKILA/build_native.py", line 159, in <module>
Android NDK: The following directories were searched:
build(opts.ndk_build_paSM,opts.android_platform,opts.build_mode)
File "C:/Users/SM/workspace/KIKILA/build_native.py", line 146, in build
do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
File "C:/Users/SM/workspace/KIKILA/build_native.py", line 82, in do_build
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
Exception: Build dynamic library for project [ C:\Users\SM\workspace\KIKILA ] fails!
Android NDK:
make.exe: Entering directory `C:/Users/SM/workspace/KIKILA'
make.exe: Leaving directory `C:/Users/SM/workspace/KIKILA'
The Selected NDK toolchain version was 4.8 !
**** Build Finished ****
The problem was due to the build_native.py script.
The build_native.py hasn't been maintained for ages and it has been deprecated. So you can't rely on it to build your Android project. But Cocos guys haven't make it clear to developers.
Try use cocos run command instead.
You could run the following command to build and run your project.
cd KIKILA
cocos run -p android
Before running the cocos command, you might need to configure it:
cd COCOS2DX_ROOT(your cocos2d-x folder)
python setup.py

How to fork a Framework Library

After downloading the Android Source Code using the repo command as suggested on the page:
repo init -u https://android.googlesource.com/platform/manifest
I was able to compile the whole project without issue using make.
What I would like to do is compile my own fork of android.media.MediaPlayer, but I am lost as to how to set up the build.
I tried using ndk-build in /frameworks/base/media/libmedia, and got the following output:
Android NDK: WARNING:/home/user/android/WORKING_DIRECTORY/frameworks/base/media/jni/Android.mk:media_jni: non-system libraries in linker flags: -lpthread
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi] Compile++ thumb: audioeffect_jni <= android_media_AudioEffect.cpp
/home/user/android/WORKING_DIRECTORY/frameworks/base/media/jni/audioeffect/android_media_AudioEffect.cpp:22:23: fatal error: utils/Log.h: No such file or directory
compilation terminated.
make: *** [/home/user/android/WORKING_DIRECTORY/frameworks/base/media/obj/local/armeabi/objs/audioeffect_jni/android_media_AudioEffect.o] Error 1
How could I compile a .jar that contained libmedia and android.media.MediaPlayer so that I could simply drop it into a project and use that instead of the default android.media.MediaPlayer?

Android NDK sample build error linux

Hello I am new to Android and I am trying to build the hello-jni sample that is included in the NDK but I get the error below, any idea how to fix it?
15:57:10 ** Build of configuration Default for project HelloJni **
/media/Project/adt-bundle-linux-x86-20131030/adt-bundle-linux-x86-20131030/android-ndk-r9c/ndk-build
all Android NDK: WARNING: APP_PLATFORM android-19 is larger than
android:minSdkVersion 3 in ./AndroidManifest.xml [armeabi-v7a]
Compile thumb : hello-jni <= hello-jni.c arm-linux-androideabi-gcc:
error trying to exec
'/media/Project/adt-bundle-linux-x86-20131030/adt-bundle-linux-x86-20131030/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/as':
execv: Exec format error make: *
[obj/local/armeabi-v7a/objs/hello-jni/hello-jni.o] Error 1
15:57:10 Build Finished (took 230ms)
This is what I am using:
Ubuntu 10.04.4
ADT bundle for linux (v22.3.0-887826)
NDK r9c
Thanks in advance
The WARNING is correct, and should be ignored.
Regarding the gcc error, you probably have a problem with installation of NDK. How did you unpack it? Check
ls -l /media/Project/adt-bundle-linux-x86-20131030/adt-bundle-linux-x86-20131030/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/arm-linux-androideabi/bin/as
This should be a symbolic link to ../../bin/arm-linux-androideabi-as, and both should have executable permissions.

Categories

Resources