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:
Related
I am trying to implement CI on app which contains native code in C++ using github actions
When i am running workflow it's says that there is no headers near the .cpp, but it is here and i have setted include directories in build.gradle and Android.mk file, the build is fine on local PC(windows)
[armeabi-v7a] Compile++ thumb: samp <= CAuthentication.cpp In file
included from
/home/runner/work/client/client/app/src/main/cpp/CAuthentication.cpp:3:
/home/runner/work/client/client/app/src/main/cpp/main.h:23:10: fatal
error: 'vendor\RakNet\SAMP\samp_netencr.h' file not found
#include "vendor\RakNet\SAMP\samp_netencr.h"
file CAuthentication.cpp is in the same directory as directory "vendor"
I also tried to set environment variable in github job but it does not help
If you're using backslashes in your include directives as the error seems to suggest, try to change them into forward slashes:
#include "vendor/RakNet/SAMP/samp_netencr.h"
Also check the path for case correctness. Windows has a case-insensitive filesystem, while the CI might be running some form of Linux.
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.
I want to use dlib library in my android project which is written in c++.
I selected c++ language because it will support iOS also.
So I follow these steps:
I created android ndk project and I included that dlib library
directly in my c++ code folder.
I import .h files and I generated a app gradle file in android studio
project.
But when I am getting library .h files errors, means internal .h files getting errors.
Error:error: linker command failed with exit code 1 (use -v to see invocation)
Error:Build command failed.
Error:org.gradle.internal.UncheckedException:
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?
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.