How do you use the build_native.sh tool? - android

I followed this tutorial on raywenderlich.com and I came into a stop on the part where I need to build the native C++ libraries for Android Development.
I am using Mac OS,Cocos2d-x v2.0.1 (latest version), have my Android SDK and NDK set up, and my Eclipse (Helios) with the correct plug-ins needed for C/C++. Now I'm have trouble building the Cocos2d-x libraries for Android development. I'm using the build-native.sh tool. If I use it on the terminal like so:
xxxxx-xxxxx-imac:proj.android xxxxx$ ./build-native.sh
I get the following:
Using prebuilt externals
Android NDK: WARNING: Ignoring unknown import directory: /Users/xxxxx/Desktop/LANCE/COCOS2DX/cocos2d-2.0-rc2-x-2.0.1/cocos2dx/platform/third_party/android/prebuilt
Android NDK: /Users/xxxxx/Desktop/LANCE/COCOS2DX/cocos2d-2.0-rc2-x-2.0.1/CocosDenshion/android/Android.mk: Cannot find module with tag 'cocos2dx' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
make: Entering directory `/Users/xxxxx/Desktop/LANCE/COCOS2DX/cocos2d-2.0-rc2-x-2.0.1/testproj2/proj.android'
jni/Android.mk:19: *** Android NDK: Aborting. . Stop.
make: Leaving directory `/Users/xxxxx/Desktop/LANCE/COCOS2DX/cocos2d-2.0-rc2-x-2.0.1/testproj2/proj.android'
I looked at /Users/xxxxx/Desktop/LANCE/COCOS2DX/cocos2d-2.0-rc2-x-2.0.1/cocos2dx/platform/third_party/android/prebuilt but this directory does not exist (the platform folder is missing from the cocos2dx folder)
How do I fix this?
Thanks in advance.
EDIT: After looking through the scripts, I noticed that the cocos2dx folder in the cocos2dx root folder does not have an Android.mk file.

A re-unpacking of the Cocos2d-x ZIP did the trick. Turns out the files needed were deleted (for some reason) in the Cocos2d-x root folder.

build_native tool is obsolete now, Cocos2d-Console is used instead.

Related

Android NDK: Could not find platform files (headers and libraries)

Error message:
Actually,my environment is good when my disk not broken. However,when I change a new disk, download new ndk package, then set my NDK_ROOT, and ANDROID_NDK, like this:
Env variables:
my ndk-build is not working. Is something wrong in my environment?
Here is an example for Android JNI: https://github.com/russell-shizhen/JniExample, you should start from some tutorial project first.

How to build host static library with Android NDK?

I'm trying to build android adb tool from the sources. Since file Android.mk is presented i'm running ndk-build tool to build it. But unfortunately i'm having following errors:
/Users/user/Documents/dev/tmp/adb/jni/Android.mk:95: /softdev/android-ndk-r10c/build/core/build-host-static-library.mk: No such file or directory
/Users/user/Documents/dev/tmp/adb/jni/Android.mk:183: /softdev/android-ndk-r10c/build/core/build-host-executable.mk: No such file or directory
Android NDK: Trying to define local module 'adbd' in /Users/user/Documents/dev/tmp/adb/jni/Android.mk.
Android NDK: But this module was already defined by /Users/user/Documents/dev/tmp/adb/jni/Android.mk.
/softdev/android-ndk-r10c/build/core/build-module.mk:34: *** Android NDK: Aborting. . Stop.
I've checked files (build-host-*-*.mk) are absent for some reason. I've found them in someone's git repo, but it's for windows. After copying build-host-*-*.mk to my local ndk folder i'm getting another errors:
Android NDK: /Users/user/Documents/dev/tmp/adb/jni/Android.mk:adb: Unknown LOCAL_MODULE_CLASS value: HOST_STATIC_LIBRARY
/softdev/android-ndk-r10c/build/core/build-module.mk:29: *** Android NDK: Aborting . Stop.
So it seems that just copying that files is not enough. How can i make it built?
adb is a host tool (which runs on your PC rather than on the Android device), and NDK has no support for building host executables. It does provide some stubs but the feature was never fully implemented.
The git repo you are linking to is not the official NDK r7b but a patched version with host target support added. This includes a bit more than just a single file – see the full diff here.
You will need to apply this patch (or copy all the scripts which were modified) to your local NDK setup. If you are running an NDK version other than r7b, you may have to make some additional modifications.
See also my question, in which I basically ran into the same issue.

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 integrate Foxit PDF Reader in Android?

I have followed these steps in order to compile the Foxit library:
1) Download and install the Eclipse IDE (http://www.eclipse.org/), the Android SDK, ADT plugin for Eclipse, and the Android NDK (http://developer.android.com/sdk/index.html).
a) For Windows use, also download and install Cygwin (http://www.cygwin.com/). During Cygwin setup, make sure to include the “Devel -> make” package.
2) Download the Foxit embedded SDK Package.
3) Extract the Foxit embedded SDK Package to any directory.
4) Place the Foxit embedded SDK library and header files in fpdfemb_android/examples/demos/bin and include directory.
5) Build the NDK layer.
a) Open the Android.mk makefile in fpdfemb_android/examples/demos/demo(like “demo_view”)/jni/ in a text editor and fill in the Foxit library name in the area designated for LOCAL_LDLIBS, dropping the lib prefix:
The demo is shipped as:
LOCAL_LDLIBS +=../bin/# fill in library name here
To add downloaded libfoxit.a from step 2, fill in as:
LOCAL_LDLIBS :=../bin/libfoxit.a
If the library provide is not named “libfoxit.a” please adjust accordingly.
b) Open Cygwin (Windows), or a terminal (Linux based), and navigate to the fpdfemb_android/examples/demos/demo(like “demo_view”) directory. Run “ndk-build –B” to build the NDK/JNI layer.
Example:
me#myStation /myProjectPath/ > ndk-build –B
This assumes that the ndk directory is part of the $PATH environment variable. The command can also be qualified with the path to the NDK directory.
But then I'm getting this error in the terminal:
Android NDK: WARNING:jni/Android.mk:fpdfembedsdk: non-system libraries in linker flags: jni/../../bin/libfoxit.a
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
make: * No rule to make target `–B'. Stop.
Could you please tell me if there is any way to resolve this?
Thank you.
I recommend trying Foxit's new MobilePDF SDK for Android which will provide most of the functionality found in the embedded PDF SDK that you've previously tried but it includes a user interface and can be integrated into your Android projects quickly.
http://www.foxitsdk.com/products/mobile-pdf-sdk/
This SDK replaces Foxit's embedded SDK.

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.

Categories

Resources