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.
Related
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:
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?
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.
I have been following this tutorial http://developer.samsung.com/android/technical-docs/Porting-and-using-LAME-MP3-on-Android-with-JNI, however I dont seem to get it to compile when it comes to Compilation with NDK section. The following is the error that I get
Android NDK: WARNING: APP_PLATFORM android-17 is larger than android:minSdkVersion 7 in ./AndroidManifest.xml
[armeabi] Compile thumb : mp3lame <= bitstream.c
jni/./libmp3lame/bitstream.c:33:18: fatal error: lame.h: No such file or directory
compilation terminated.
make.exe: * [obj/local/armeabi/objs/mp3lame/./libmp3lame/bitstream.o] Error 1
I have added
LOCAL_C_INCLUDES += jni/include
to Android.mk, so it can find the ".h" needed.
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.