how to build android_external_openvpn_ics with ndk-build - android

There is a project on github --> https://github.com/CyanogenMod/android_external_openvpn/tree/ics, after download the sourcecode, I just want to build it use NDK-BUILD command in Linux(Centos 6.3), but the author does not say anything about it;
So, I just ndk-build it (I have test ndk-build is ok), it shows:
Android NDK: Could not find application project directory !
Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.
What may cause this warning? And how can I build it, thx!

This usually happens when you invoke ndk-build from incorrect diretory. You must be in folder which contains jni subdirectory.
Or alternatively do what error message tells you - specify NDK_PROJECT_PATH to correct folder.
NDK_PROJECT_PATH=/home/cenuser/android/sphinx/PocketSphinxDemo
export=NDK_PROJECT_PATH

Related

Unable to make and compile my NDK project on eclipse with Ubuntu

I have followed tutorials to implement NDK functionality in a test project. Created jni folder and added .mk and .c file. NDK is linked and the C++ make file has link to ndk-build file in NDK folder.
On building project i am getting this error :-
Build of configuration Default for project HomeTestingNDK **
/home/falooka/adt-bundle-linux-x86-20130917/ndk/ndk-build all
Compile thumb : HomeTestingNDK <= native.c
make: /home/falooka/adt-bundle-linux-x86-20130917/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
make: * [obj/local/armeabi/objs/HomeTestingNDK/native.o] Error 127
Build Finished **
Now the issue is that 'make' is going for arm-linux-androideabi-gcc while this file doesn't exist in the folder and instead there is arm-linux-androideabi-gcc-4.6. Now I am totally struck how to solve this issue after googling for a while now.
Thanks in advance.
I was able to resolve my issue by following these multiple steps :
1) For some stupid reason, arm-linux-androideabi-gcc was missing in the ndk directory. So i tried re-installing the zip and extracted it inside the home folder instead of my drive to avoid ownership errors. Now file was there and this error was gone !
2) Then i was getting "Android NDK java.lang.UnsatisfiedLinkError: findLibrary returned null" error which had something to do with libraries missing. After reading some posts, it was prominent that the libs/ folder in project directory should have .so files which were not there. I am using OpenCv with my project so i updated the environment links and put explicit path to ndk-build file in 'make' to make sure it finds ndk-build.
3) I also did this : https://stackoverflow.com/a/7646921/1016544
So finally its compiling and shows building of .so files before installing and runs perfectly.

how to build openssl on android

I am trying to build openssl on android (got from https://github.com/guardianproject/openssl-android). need to make .so file of this and use in another android project actually. When I try to add all folders of downloaded openssl and build in prompt through ndk-build command, I get an error like this:
Android NDK: Trying to define local module 'openssl' in workspace/project/apps/Android.mk.
Android NDK: But this module is was already defined by workspace/project/apps/Android.mk.
android-ndk-r8b/build/core/build-module.mk:34:
*** Android NDK: Aborting.. Stop.
Please let me know how to build .so file!!
Please check Android.mk, which is the make file for android. I think there is a silly mistake on that file.

error: jni.h: No such file or directory

I am getting error while trying to build android ndk project:
error: jni.h: No such file or directory
But: locate jni.h command show me:
locate jni.h
/usr/lib/jvm/java-6-openjdk-i386/include/jni.h
What is wrong in my actions?
EDIT:
If I hardcode it in the source code it work but I have a lot of files that are using this header. What I need to do that all my files can see /usr/lib/jvm/java-6-openjdk-i386/include/jni.h
?
Try setting the installation location of your NDK in PATH in your rc file, let's say ~/.bashrc:
NDK=/path/to/your/ndk/location
export PATH=$PATH:$NDK
Source the rc file by running source ~/.bashrc.
Now when you run ndk-build, it will setup the whole build environment for you by running make command against a bunch of make files under $NDK/build/core, it will setup correct header file search path for your project depending on the android:targetSdkVersion setting in AndroidManifest.xml.
The jni.h needed by your NDK project is located under $NDK/platforms/android-14/arch-arm/usr/include.
Android NDK projects will not use any JNI header files under your JDK installation, files under /usr/lib/jvm/.... will never be touched.

Fixing Eclipse errors when using Android NDK and std::vector

I'm using eclipse to develop an android app that also uses the ndk. I vectors in my app and I've done the necessary stuff to get them by including
APP_STL := stlport_static
In my Application.mk
Everything is working fine it compiles and runs but Eclipse keeps giving me errors when I use the vectors
std::vector<int> blah
for example creates an error. If I delete the error and keep going it compiles and runs fine.
I've added
${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include
In my project config under C++ General -> Paths and Symbols -> include
It resolves #include <vector> fine (before I added the path above I had an error for this) but I still get errors using the vectors.
How can I get eclipse to stop giving me errors for this?
EDIT:
example error: Symbol 'vector' could not be resolved
EDIT 2:
I tried to add
using namespace std;
and then using vector blah and that causes a different error:
Invalid template arguments
I've added ${NDKROOT}/sources/cxx-stl/gnu-libstdc++/include
In my project config under C++ General -> Paths and Symbols -> include
Yes, that's it. I've tried to add the same with the same result.
However, if you add stl_port headers
${NDKROOT}/sources/cxx-stl/stlport/stlport
It will do the trick. Of course it is not necessary to change
APP_STL := stlport_static
as it works only in eclipse indexes. It will be usefull until you are going to use something that exists in gnu-libstdc++ and doesn't exist stl-port.
Blockquote
I am suing eclipse indigo rc2.
I added following line in Android.mk
LOCAL_C_INCLUDES += ${NDKROOT}/sources/cxx-stl/stlport/stlport
and Added following line in Application.mk
APP_STL := stlport_static
then automatically my ndk stlport path added in
Properties -> C++ General -> Paths and Symbols -> include
good luck! ^^
At first, we met the same problem with map and tried to add "Paths and Symbols" as suggested, however it still wouldn't work.
Later on, instead of
#include <map>
we used
#include <stl/_map.h>
The error went away and then we switched back to include <map>. Eclipse no longer complained that "Symbol could not be resolved".
It seems eclipse has a cache and somehow it can get messed up unless you specifically tell it the right place to find the symbols.
I do not know at what stage it worked, but:
Add to Application.mk APP_STL := gnustl_static
Add include to Project properties->C/C++ General -> Paths and Symbols 'NDK root path'/'your directory to android platform'/arch-arm/usr/include
'NDK root path'/sources/cxx-stl/gnu-libstdc++/4.9/include
'NDK root path'/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/bits
Turn off all warnings errors in Project properties->C++ General->Code Analisis.
Project properties->C++ Build-> Builder Settings -> Uncheck use default build command. Build command set empty.
Next configure NDK Builder: Project properties-> Builders-> New-> Program and fill Name (your name build conf), Location (path to NDK root directory), Working directory (path to project dir). -> Refresh and check specific resources (your libs folder in project). -> Build Options check Specify working set of relevant resources and change 'jni' folder with your source.
worked in Ubuntu 15.04. Eclipse 3.8.1. Android NDK r10e.

How can I set an Android Makefile to copy/rename files?

According to the Android online docs there's currently no way to specify multiple/mixed file extensions for the gcc compiler in an Android makefile. The source I'm using, a public project, has multiple extensions and in order to get it to compile I need to rename the files with the other extensions .cpp before build.
I set up a project subfolder I can copy these files into and rename them and then just link to them from there but I'd like to make this step a part of the build process so that any time those files are modified I can be certain this build will reflect those changes.
I'm not sure how to tell the Android.mk file to copy the files and rename them. I tried this but it doesn't work:
cp '$(LOCAL_PATH)/$(SOURCE_ROOT)/Sprite.mm' '$(LOCAL_PATH)/$(MM_RENAMES)/Sprite.cpp'
I receive the following error:
Anhdroid.mk:10 * missing separator. Stop.
Thanks,
Update
Alternatively, if someone knows a way to embed a call to execute a shell/Perl script in the beginning of the makefile would work too.
Ok, got it, this worked to copy files:
$(shell cp -fr $(LOCAL_PATH)/$(SOURCE_ROOT)/Sprite.mm $(LOCAL_PATH)/$(MM_RENAMES)/Sprite.cpp)
And this also works to run an outside script:
$(perl scripts/foo.pl)

Categories

Resources