i will run a cocos project in android Studio but when type command cocos compile -p android in cmd.exe say error in ndk.
and android.mk is :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END
LOCAL_STATIC_LIBRARIES := cocos2dx_static
# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END
my cmd
As now According to me you are using NDK 12 or greater.
These NDK by default add arm64-v8a architecture support. You don't have libfreetype.a file in cocos2d/external/freetype2/prebuilt/android/arm64-v8a/ folder because cocos2d not generate by default, it slow down the compiling speed.
Solution is you can use NDK 11 or lesser
otherwise use latest version of cocos2d-x and enable ABI support to all arch armeabi armeabi-v7a x86 arm64-v8a instead of armeabi only
Some of concerning topic/issue
https://github.com/cocos2d/cocos2d-x/issues/15713
https://github.com/cocos2d/cocos2d-x/issues/15566
Related
I was able to successfully pass in APP_CFLAGS via eclipse through via the settings' ndk-build command as
ndk-build -B NDK_DEBUG=1 APP_CFLAGS=-DTEST
I have now switched to Android studio and was trying to do it directly in the makefile with the following, but its not taking:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
APP_CFLAGS += -DTEST
LOCAL_SRC_FILES:= test.cpp
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
It builds fine, but my TEST variable is never set in the C++ code.
How can I add it to the makefile?
Or, How can I add it to Android Studio project settings?
You could use LOCAL_CFLAGS for C/C++ code additional flags or LOCAL_CPPFLAGS for C++ code in Android build system.
LOCAL_CFLAGS := -DTEST=1
I have a third part shared library (.so) with some classes (C++). I would like to use this library in my Android App. I am planning to write a piece of code in C++ too, for access third part shared library. The code that access third part shared library will be put in a shared library to (mySHaredLibrary.so). My doubt is how to compile mySHaredLibrary.so, how I can indicate in my make file that mySHaredLibrary.so depends on third part shared library.
I am using android ndk r10d for windows 64 bits. (https://developer.android.com/tools/sdk/ndk/index.html)
Let's say the external lib is called libThirdParty.so, and you have .h headers you include from your sources to use it. Here is what you can do:
Place your .so files for each architectures under jni/ThirdPartyLib/<abi> (Android ABIs supported by the NDK right now are armeabi, armeabi-v7a, x86, x86_64, arm64-v8a, mips, mips64). You should have at least one version of your lib for armeabi or armeabi-v7a and for x86, and it's of course better to have one for all of the supported architectures.
Then, place your .h files under jni/ThirdPartyLib/include
Now, here is what you can have inside your Makefiles:
Android.mk:
LOCAL_PATH := $(call my-dir)
# ThirdParty prebuilt
include $(CLEAR_VARS)
LOCAL_MODULE := ThirdParty
LOCAL_SRC_FILES := ThirdPartyLib/$(TARGET_ARCH_ABI)/libThirdParty.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ThirdPartyLib/include
include $(PREBUILT_SHARED_LIBRARY)
# Your lib
include $(CLEAR_VARS)
LOCAL_MODULE := mySHaredLibrary
LOCAL_SRC_FILES := source1.cpp source2.cpp
LOCAL_SHARED_LIBRARIES := ThirdParty
include $(BUILD_SHARED_LIBRARY)
Application.mk
APP_ABI := all # can be "armeabi-v7a x86 mips..." depending on what you support.
APP_PLATFORM := android-14 # should be the same number than in Android project's minSdkVersion.
Hello i'm new to NDK and C/C++ development with android application. i'm having problem in my android application in compiling android application with c/c++.. I added some custom libraries for my sqlite. Could anyone explain what's happening to my project and is there something that i need to configure with my MK file? i added this to my mk file APP_ABI := armeabi armeabi-v7a
Here is my Android.mk file
APP_PLATFORM := android-8
#WHAT DO I NEED..
APP_ABI := armeabi armeabi-v7a
#TARGET_ARCH = arm
#TARGET_ARCH_ABI = armeabi-v7a
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ExtFunc
LOCAL_SRC_FILES := extension-functions.c
LOCAL_SRC_FILES += sqlite3.c
LOCAL_SHARE_LIBRARIES := sqlite3
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ProximityAPI
LOCAL_SRC_FILES := ProximitySearch.c
LOCAL_SRC_FILES += sqlite3.c
LOCAL_SHARE_LIBRARIES := sqlite3
include $(BUILD_SHARED_LIBRARY)
When i started running my project the armeabi-v7a libraries
automatically removed in compilation.
I used NDK R10b
To make things clear the two library is working in different project but when i combine them it removed my HERE-Map Libraries under the armeabi-v7a in compiling my android application.
Hope someone could help me i'm confused..
Thanks!
APP_ABI should go into your Application.mk file within the jni folder. It might not exist by default so you might have to create one. Also, if you are building only for ARM there is no need to specify that explicitly. If you are looking to target multiple architecture like x86 you could add that to you APP_ABI parameter.
I'm trying to integrate static library libAT_int.a
I have successfully integrated it in iOS app.
lipo -info libAT_int.a
Architectures in the fat file: libAT_int.a are: armv6 armv7
But when i'm integrating it with Android NDK. I'm getting error during ndk build
error: jni/libAT_int.a:1:1: invalid character
Android.mk has following content :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := AT
ifeq ($(APP_ABI), armeabi-v7a)
LOCAL_SRC_FILES := libAT_int.a
else
LOCAL_SRC_FILES := libAT_int.a
endif
LOCAL_CPP_FEATURES += rtti exceptions
LOCAL_CPP_EXTENSION := .cpp .h
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := MusicSDK
LOCAL_SRC_FILES := MusicSDK.cpp
LOCAL_CPP_FEATURES += rtti exceptions
LOCAL_CPP_EXTENSION := .cpp .h
LOCAL_STATIC_LIBRARIES := AT
include $(BUILD_SHARED_LIBRARY)
You can't use a static library built for iOS when building for Android, you need a static library built specifically for Android.
I've searched a lot of topics about linking libpng to my android ndk project but I've found right answer for my problem and I hope somebody will help me.
This is hierarchy of my project:
jni
different_cpp_files
different_hpp_files
Android.mk
libpng
different_cpp_files
different_hpp_files
Android.mk
Android.mk in libpng folder:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LS_C=$(subst $(1)/,,$(wildcard $(1)/*.c))
LOCAL_MODULE := png
LOCAL_SRC_FILES := \
$(filter-out example.c pngtest.c,$(call LS_C,$(LOCAL_PATH)))
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lz
include $(BUILD_STATIC_LIBRARY)
I suppose that everything is right here..
Android.mk in jni folder:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LS_CPP=$(subst $(1)/,,$(wildcard $(1)/*.cpp))
LOCAL_MODULE := pacman
LOCAL_CFLAGS := -Wno-psabi
LOCAL_SRC_FILES := $(call LS_CPP,$(LOCAL_PATH))
LOCAL_LDLIBS := -landroid -llog -lEGL -lGLESv1_CM -lOpenSLES
LOCAL_STATIC_LIBRARIES := android_native_app_glue png
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
$(call import-module,libpng)
The last line shows that I got libpng like native_app_glue lib(in the directory of android-ndk sources) Now I want to compile libpng from my project. What I need to change in Android.mk file?
i've got another way for you:
Download all files from here and paste it into a new folder anywhere on your system:
https://github.com/julienr/libpng-android
go into the folder and run:
./build.sh
You will get an libpng.a file in [YOUR_FOLDER]/obj/local/armeabi/libpng.a
Copy this file into:
[YOUR_ANDROID_NDK_FOLDER]/platforms/[ALL_FOLDERS_IN_HERE]/arch-arm/usr/lib/
now you can use libpng in all your projects with the simple line:
LOCAL_LDLIBS += -lpng
you only have to include this in your cpp's:
#include <png.h>
Have fun!