fatal error: Box2D.h: No such file or directory - android

I have developed a game in xcode using cocos2d-x 2.2.3 and box2d. Now i am trying to port from ios to android. However i am getting the following error while build through terminal.
In file included from jni/../../Classes/LevelScene.cpp:1:0:
jni/../../Classes/LevelScene.h:6:19: fatal error: Box2D.h: No such file or
directory
compilation terminated.
make: ***
[obj/local/armeabi/objs/cocos2dcpp_shared/__/__/Classes/LevelScene.o] Error 1
Please advice.

I just copied the files which is in box2d folder and placed in classes folder. It worked.

The right way to do this is to allow CMake to find the directory. In the CMakeLists.txt file, use it like this:
set(Box2D_SOURCE_DIR "/path/to/your/folder/liquidfun-1.1.0/liquidfun/Box2D")
include_directories (${Box2D_SOURCE_DIR})
You could also set the directory relatively:
set(Box2D_SOURCE_DIR "..")

Related

Xamarin Android .AAR results in DirectoryNotFoundException

When trying to reference a .AAR java library binding we received the following error:
Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.DirectoryNotFoundException: Could not find a part of the path "\\####\####\Developer\Mobile Apps\Android\####.Android\Project Files\####.Xamarin.Android\obj\Release\__library_projects__\IntercomForXamarinAndroidBase\library_project_imports\res\drawable-xxhdpi\intercomsdk_chat_bubble_right_aligned_notail.9.png" (XA0000) (####.Xamarin.Android) monodroid
Turns out it was because the file path was too long.
Installed windows hotfix:
A file copy operation fails when files or folders have long paths in Windows Explorer

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.

Error 1 libavcodec.so File format not recognized Android GL Live Wallpaper

I am trying to make a Live Wallpaper for android that plays an .mp4 video located on the device in android-asset (with the example I am using, it actually copies the file to the sdcard at runtime/doesn't matter)
I found this example
And using this post I was able to get my eclipse set up with NDK and building the project.
When building in eclipse using the NDK plugin I get this error in my problems window:
Description Resource Path Location Type
make: *** [libs/armeabi/libavcodec.so] Error 1 GLWallpaperVideoDemo-master C/C++ Problem
make: *** Deleting file `libs/armeabi/libavcodec.so' GLWallpaperVideoDemo-master C/C++ Problem
I get the same error if I try to run ndk-build from command prompt.
I downloaded the project from the link above and then imported into eclipse. I added the lib GLWallpaperService to the build path, and made sure my NDK was setup. Knowing that the lib folder changed to libs I also tried moving the GLWallpaperService to the libs folder, which didn't help.
The project builds without NDK just fine in eclipse but obviously errors when trying to run the wallpaper because the native libraries were not built.
How can I resolve this error?
The package you get by git clone https://github.com/frankandrobot/GLWallpaperVideoDemo.git is Linux oriented. The file jni\ffmpeg-android\build\ffmpeg\armeabi\lib\libavcodec.so and many others are simply symbolic links to actual files.
To make this all work easily on Windows, I suggest to go to the jni\ffmpeg-android\build\ffmpeg\armeabi\lib folder, and run
del *.so
copy libavcodec.so.52.99.1 libavcodec.so
copy libavcore.so.0.16.0 libavcore.so
copy libavdevice.so.52.2.2 libavdevice.so
copy libavfilter.so.1.69.0 libavfilter.so
copy libavformat.so.52.88.0 libavformat.so
copy libavutil.so.50.34.0 libavutil.so
copy libswscale.so.0.12.0 libswscale.so
The issue might be because of a corrupted so file. Try to build the ffmpeg library again or find another version. Because I have a different error in eclipse when I try to compile the project:
C:/Android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip:./libs/armeabi/libavcodec.so: File format not recognized
And when I search for this error it seems like the error is because of a corrupted file: NDK prebuilt shared library file format not recognized
Or the library is not in a format that Android can use:
Error in linking C++ static library with android ndk(Error: file format not recognized)

How do you use the build_native.sh tool?

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.

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.

Categories

Resources