I have successfully generated .h file using javah, now i want to build my android-ndk hello world project. But it says command not found
nespl#nespl-pc:~$ ndk-build
ndk-build: command not found
this is my path
nespl#nespl-pc:~$ echo $PATH
/home/nespl/android-ndk-r8/ndk-build:/home/nespl/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/nespl/adt-bundle-linux-x86/sdk/tools:/home/nespl/adt-bundle-linux-x86/sdk/platform-tools:/home/nespl/gsutil
Your PATH should include the root directory of your NDK:
export PATH=$PATH:/home/nespl/android-ndk-r8
instead of your current:
export PATH=$PATH:/home/nespl/android-ndk-r8/ndk-build
Related
Please help me. I try to build PJSIP library in Windows for Android by using Cygwin terminal. I follow steps exactly, but when I write $ ./configre-android I get this error - >
$ ./configure-android
./configure-android: line 3: $'\r': command not found
./configure-android: line 5: $'\r': command not found
./configure-android: line 71: syntax error near unexpected token `$'do\r''
'/configure-android: line 71: ` for i in `$NDK_OUT`; do
I used this steps to build sources are
Download sources from PJSIP site. Pay attention if you will compile
on Windows machine download .zip file, if on Unix machine (including
OS X) then download .bz2 file.
Go to pjlib/include/pj/ from the downloaded sources. Create (or
overwrite) a file called config_site.h. Copy the following code
snippet
#define PJ_CONFIG_ANDROID 1
#include <pj/config_site_sample.h>
Open Cmd or Terminal
Go to pjsip root folder (the downloaded sources)
$ cd /path/to/your/pjsip/dir
Export bash var ANDROID_NDK_ROOT as a environment variable.
Variable value should be the path of android ndk directory.
$ export ANDROID_NDK_ROOT=/path_to_android_ndk_dir
Perform build for target armeabi
$ ./configure-android
If you need to perform build for target arm64-v8a do $
TARGET_ABI=armeabi-v8a ./configure-android --use-ndk-cflags
target armeabi-v7a do $
TARGET_ABI=armeabi-v7a ./configure-android --use-ndk-cflags
target x86 do $ TARGET_ABI=x86 ./configure-android --use-ndk-cflags
Compile sources
$ make dep && make clean && make
This fixed problem for me:
tr -d '\015' < configure-android > configure-android2
After this launch configure-android2, not configure-android
I am developing and android application in mac using Eclipse for android-ndk. I have already given NDK path in Eclipse. At the end when I am giving this command to build my application using android-ndk but getting the following errors:
command: ndk-build
ndk-build-bash: ndk-build: command not found
My Terminal Commands:
Muhammads-MacBook-Pro:~ UsmanKhan$ cd downloads
Muhammads-MacBook-Pro:downloads UsmanKhan$ cd 26thMarch2014
Muhammads-MacBook-Pro:26thMarch2014 UsmanKhan$ cd a2zLatest
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls
AndroidManifest.xml gen proguard-project.txt
Thumbs.db ic_launcher-web.png project.properties
assets libs res
bin lint.xml src
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls bin/classes/
com
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls bin/classes/com/testing/ndk
BuildConfig.class R$dimen.class R$string.class
FibLib.class R$drawable.class R$style.class
MainActivity.class R$id.class R.class
R$attr.class R$layout.class
R$color.class R$menu.class
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ mkdir jni
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin /classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls jni
com_testing_ndk_FibLib.h
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ls jni
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin/classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ javah -jni -classpath bin/classes/ -d jni/ com.testing.ndk.FibLib
Muhammads-MacBook-Pro:a2zLatest UsmanKhan$ ndk-build
-bash: ndk: command not found
At the end i am getting ndk-build error.
Instead of ndk-build command, simply type ~/Desktop/AndroidNDK/android-ndk-r10d/ndk-build in your terminal.
I didn't give any explicit values for ANDROID_NDK_ROOT and ANDROID_SDK_ROOT, i just give the location of my NDK in my eclipse preferences. Can you please guide me in this thing
According to the Android folks on the Android NDK group (see Recommended NDK Directory?), uou should always provide values for ANDROID_NDK_ROOT, ANDROID_SDK_ROOT and ANDROID_SDK_HOME. Here is what they are used for:
ANDROID_NDK_ROOT → installation dirctory of NDK
ANDROID_SDK_ROOT → installation dirctory of SDK
ANDROID_SDK_HOME → location of SDK-related user files, defaults to ~/.android/ on Unix.
Put the tools on-path and export the env vars. Here's my .bash_profile for OS X.
$ cat ~/.bash_profile
export PS1="\h::\W$ "
# Android
export ANDROID_NDK_ROOT=/opt/android-ndk-r10d
export ANDROID_SDK_ROOT=/opt/android-sdk-macosx
export ANDROID_SDK_HOME=~/.android
export JAVA_HOME=`/usr/libexec/java_home`
export PATH="$ANDROID_SDK_ROOT/tools/":"$ANDROID_SDK_ROOT/platform-tools/":"$PATH"
Then, source your profile changes (or log-off and then log-in).
I'm new to Linux (Ubuntu) and I had a problem building the libraries in my project.
I added the android ndk to the PATH like this:
export PATH=$PATH:/android-ndk-r9b
and to Eclipse
but when I try to use the
ndk-build
command, I get this output:
ndk-build: command not found
Any help?
Your PATH should include the root directory of your NDK:
export PATH=$PATH:/home/.../android-ndk-xxx
How can I build my source for android with NDK.
Already I download ndk and I don't know how can I set arch compiler path.
This is my "build-for-android.sh" code:
#!/bin/sh
cairo=system
curl=system
pal=android
alsa=no
pulse=no
sles=yes
ffmpeg=yes
gallium=no
egl=yes
glx=no
PKG_CONFIG_PATH=$MOONLIGHT_PREFIX/lib/pkgconfig
if [ -d /usr/X11/share/aclocal ]; then
export ACLOCAL_FLAGS="-I /usr/X11/share/aclocal"
fi
./autogen.sh --host=arm-linux-androideabi --prefix=$MOONLIGHT_PREFIX --with-manual-mono=yes --with-testing=no --enable-browser-support --disable-desktop-support --with-unwind=no --with-ffmpeg=$ffmpeg --with-alsa=$alsa --with-pulseaudio=$pulse --with-opensles=$sles --with-pal=$pal --with-curl=$curl --with-cairo=$cairo --with-gallium-path=$gallium --enable-sdk=no --with-egl=$egl --with-glx=$glx CFLAGS="-DPLATFORM_ANDROID -I$MOONLIGHT_PREFIX/include $CFLAGS" LDFLAGS="-L$MOONLIGHT_PREFIX/lib $LDFLAGS" CXXFLAGS="-fno-rtti -DPLATFORM_ANDROID -I$MOONLIGHT_PREFIX/include $CFLAGS"
make $#
when I run it I get error below:
checking for arm-linu-androideabi-g++... no
checking for arm-linu-androideabi-c++... no
checking for arm-linu-androideabi-gpp... no
checking for arm-linu-androideabi-aCC... no
checking for arm-linu-androideabi-cc... no
.
.
.
.
I can see them in ~/Android/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuild/linux-x86/bin/* directory.
OK. I found it.:
First, a standalone toolchain is created to make the configure script easier to use
~$ android-ndk-r5b/build/tools/make-standalone-toolchain.sh --platform=android-8 --install-dir=android-8-toolchain
Next, the toolchain's bin directory is added to the PATH.
~$ export PATH=$PATH:~/android-8-toolchain/bin/
when I am Trying to compile native C code like this:
:~/com.***.sample.ndk1$ ./ndk-build
Android NDK: Could not find platform files (headers and libraries)
Android NDK: Please run build/tools/build-platforms.sh to build the corresponding directory.
/com.***.sample.ndk1/build/core/init.mk:345: *** Android NDK: Aborting . Stop.
:~/com.***.sample.ndk1$ build/tools/build-platforms.sh
.: 39: Can't open build/tools/../core/ndk-common.sh
:~/com.***.sample.ndk1$
The above error is shows.
Could anyone answer to solve this problem?
You have to add the Your NDK location directory to Your system PATH variable:
let suppose your ndk is in /opt/android/android-ndk-r8b folder, android sdk is in /opt/android/android-sdk folder
so, you may add the following lines to your ~/.bash_profile (at the end of file) :
export PATH=$PATH:/opt/android/android-ndk-r8b:/opt/android/android-sdk
in addition You can run the following commands:
chmod -R a+r /opt/android/android-ndk-r8b
chmod -R a+r /opt/android/android-sdk