I feel like you could add your library to one of the files like: Android.mk, Application.mk, etc.
@mozartalouis @mars3142 is this correct?
I feel like you could add your library to one of the files like: Android.mk, Application.mk, etc.
@mozartalouis @mars3142 is this correct?
Maybe another way if I bring in box2d as part of /Classes/box2d/ will it collide with the prebuilt box2d?
Can you provide some hello world working example using prelibs?
I have zero experience with cmake, because I’ve used ndk-build so far.
Here’s a log from gradle console:
Build command failed.
Error while executing process /Users/piotr/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/piotr/Documents/projekty/gry/Bee/proj.android-studio/Bee/jni/Android.mk NDK_APPLICATION_MK=/Users/piotr/Documents/projekty/gry/Bee/proj.android-studio/Bee/jni/Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=0 APP_PLATFORM=android-15 NDK_OUT=/Users/piotr/Documents/pierdoly/android_studio_build/Bee/Bee/intermediates/ndkBuild/release/obj NDK_LIBS_OUT=/Users/piotr/Documents/pierdoly/android_studio_build/Bee/Bee/intermediates/ndkBuild/release/lib NDK_MODULE_PATH=/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git:/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/cocos:/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/external -DCOCOS_PREBUILT_ROOT=/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/prebuilt/android -DGEN_COCOS_PREBUILT=OFF -DUSE_COCOS_PREBUILT=ON -j4 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- D
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- G
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- E
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- N
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- _
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- U
Usage: make [options] [target] ...
Options:
-b, -m Ignored for compatibility.
-B, --always-make Unconditionally make all targets.
-C DIRECTORY, --directory=DIRECTORY
Change to DIRECTORY before doing anything.
-d Print lots of debugging information.
--debug[=FLAGS] Print various types of debugging information.
-e, --environment-overrides
Environment variables override makefiles.
-f FILE, --file=FILE, --makefile=FILE
Read FILE as a makefile.
-h, --help Print this message and exit.
-i, --ignore-errors Ignore errors from commands.
-I DIRECTORY, --include-dir=DIRECTORY
Search DIRECTORY for included makefiles.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-k, --keep-going Keep going when some targets can't be made.
-l [N], --load-average[=N], --max-load[=N]
Don't start multiple jobs unless load is below N.
-L, --check-symlink-times Use the latest mtime between symlinks and target.
-n, --just-print, --dry-run, --recon
Don't actually run any commands; just print them.
-o FILE, --old-file=FILE, --assume-old=FILE
Consider FILE to be very old and don't remake it.
-p, --print-data-base Print make's internal database.
-q, --question Run no commands; exit status says if up to date.
-r, --no-builtin-rules Disable the built-in implicit rules.
-R, --no-builtin-variables Disable the built-in variable settings.
-s, --silent, --quiet Don't echo commands.
-S, --no-keep-going, --stop
Turns off -k.
-t, --touch Touch targets instead of remaking them.
-v, --version Print the version number of make and exit.
-w, --print-directory Print the current directory.
--no-print-directory Turn off -w, even if it was turned on implicitly.
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
Consider FILE to be infinitely new.
--warn-undefined-variables Warn when an undefined variable is referenced.
This program built for x86_64-apple-darwin
Report bugs to <bug-make@gnu.org>
Build command failed.
Error while executing process /Users/piotr/sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/piotr/Documents/projekty/gry/Bee/proj.android-studio/Bee/jni/Android.mk NDK_APPLICATION_MK=/Users/piotr/Documents/projekty/gry/Bee/proj.android-studio/Bee/jni/Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-15 NDK_OUT=/Users/piotr/Documents/pierdoly/android_studio_build/Bee/Bee/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/piotr/Documents/pierdoly/android_studio_build/Bee/Bee/intermediates/ndkBuild/debug/lib NDK_MODULE_PATH=/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git:/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/cocos:/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/external -DCOCOS_PREBUILT_ROOT=/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/prebuilt/android -DGEN_COCOS_PREBUILT=OFF -DUSE_COCOS_PREBUILT=ON -j4 APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- D
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- G
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- E
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- N
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- _
/Users/piotr/sdk/ndk-bundle/build/../prebuilt/darwin-x86_64/bin/make: invalid option -- U
Usage: make [options] [target] ...
Options:
-b, -m Ignored for compatibility.
-B, --always-make Unconditionally make all targets.
-C DIRECTORY, --directory=DIRECTORY
Change to DIRECTORY before doing anything.
-d Print lots of debugging information.
--debug[=FLAGS] Print various types of debugging information.
-e, --environment-overrides
Environment variables override makefiles.
-f FILE, --file=FILE, --makefile=FILE
Read FILE as a makefile.
-h, --help Print this message and exit.
-i, --ignore-errors Ignore errors from commands.
-I DIRECTORY, --include-dir=DIRECTORY
Search DIRECTORY for included makefiles.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-k, --keep-going Keep going when some targets can't be made.
-l [N], --load-average[=N], --max-load[=N]
Don't start multiple jobs unless load is below N.
-L, --check-symlink-times Use the latest mtime between symlinks and target.
-n, --just-print, --dry-run, --recon
Don't actually run any commands; just print them.
-o FILE, --old-file=FILE, --assume-old=FILE
Consider FILE to be very old and don't remake it.
-p, --print-data-base Print make's internal database.
-q, --question Run no commands; exit status says if up to date.
-r, --no-builtin-rules Disable the built-in implicit rules.
-R, --no-builtin-variables Disable the built-in variable settings.
-s, --silent, --quiet Don't echo commands.
-S, --no-keep-going, --stop
Turns off -k.
-t, --touch Touch targets instead of remaking them.
-v, --version Print the version number of make and exit.
-w, --print-directory Print the current directory.
--no-print-directory Turn off -w, even if it was turned on implicitly.
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
Consider FILE to be infinitely new.
--warn-undefined-variables Warn when an undefined variable is referenced.
This program built for x86_64-apple-darwin
Report bugs to <bug-make@gnu.org>
Unable to find module with Gradle path ':libcocos2dx' (needed by module 'Bee'.)
What I’ve done:
in gradle.properties
Modified main gradle file:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.rosapp.bee"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.00"
ext {
cocospath = "/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git"
}
externalNativeBuild {
ndkBuild {
targets "MyGame"
arguments "NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external"
arguments "-DCOCOS_PREBUILT_ROOT=$cocospath/prebuilt/android"
arguments "-DGEN_COCOS_PREBUILT=OFF", "-DUSE_COCOS_PREBUILT=ON"
arguments "-j" + Runtime.runtime.availableProcessors()
abiFilters "armeabi-v7a"
}
}
}
Copy-pasted CMakeLists.txt from a freshly generated new project as I haven’t got one in my project.
Before you use cmake, you should learn how cmake works in Android, not only copy-paste. Firstly you can search “android ndk cmake” in google to get some knowledge, and then you should read cmake/README.md in coco2d-x repo.
I have the same problem with @piotrros . In 3.16, I can compile project with prebuilt libs but when I switch to 3.17 the prebuilt-mk folder in cocos are gone. Then when I compile android project I alway failed. Does anyone known how to fix it?.
@piotrros After work around with 3.17 I find the way to compile android with prebuilt libs.
Those steps above let me compile android successful with prebuilt libs in 3.17.
Cheer.
Thanks for help! Now gradle sync is working fine, but now it fails on app compilation. There’s tons of errors so my guess is there’s some linking error. Can you do me a favor and share your config files (gradle, Android.mk etc) or upload empty project which compiles with prebuilt?
Here are the errors:
As you can see it pretty much cannot find anything
I can’t help you solve your problem with error logs. But here are my steps from Generate prebuilt libs and config:
Environment:
Generate prebuilt libs steps:
Change these files in cocos/platform/android:
Open Cocos2dx/build/cocos2d_libs.xcodeproj
Run cocos gen-libs -m debug -c
After gen-libs finished, copy all prebuilt-mk folder from cocos2dx 3.16 to cocos2dx 3.17
Config for Cpp Project Template:
Thanks for help, but it didn’t help I still have the same linker errors like it cannot find anything. However when I switch to 3.16 everything works smoothly and I don’t even need this:
$(call import-add-path,/Users/macos/Library/Cocos2dx)
$(call import-add-path,/Users/macos/Library/Cocos2dx/external)
$(call import-add-path,/Users/macos/Library/Cocos2dx/cocos)
$(call import-add-path,/Users/macos/Library/Cocos2dx/cocos/audio/include)
in Android.mk
is there any proper guide how to generate prebuilt libs and integrate them in Android Studio project?
cocos2d-x ver 3.17
I would consider moving away from the prebuilt libraries. We plan to discontinue support for them.
why is that so? it helped alot and save to much compilation time.
It’s really because of so many Android issues with using the prebuilts (so I have been told). I use mostly iOS so I don’t have problems using the prebuilts.
Are you using CMAKE? If you can or will you can generate the pre-builts from CMAKE too.
Prebuilt has been created, but i am having issues in integrating it in android project. i am getting errors when i compile it says “cant find Cocos2d.h”
here is my android.mk file content
LOCAL_PATH := $(call my-dir)
COCOS_ROOT := /Volumes/DATA/cocos2d-x/cocos2d-x_3.17_old
include $(CLEAR_VARS)
$(call import-add-path,$(COCOS_ROOT))
$(call import-add-path,$(COCOS_ROOT)/cocos)
$(call import-add-path,$(COCOS_ROOT)/cocos/external)
$(call import-add-path,$(COCOS_ROOT)/cocos/audio/include)
LOCAL_MODULE := MyGame_shared
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES := $(LOCAL_PATH)/hellocpp/main.cpp \
$(LOCAL_PATH)/../../../Classes/AppDelegate.cpp \
$(LOCAL_PATH)/../../../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-add-path, $(LOCAL_PATH)/../../../cocos2d)
#$(call import-module, cocos)
$(call import-module, prebuilt/android)
# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END
@drelaptop may have some quick advice. Search these forums some more. I recall reading a thread recently about folks getting this working. Perhaps I can find it again too.
thanks, i am looking for multiple thread and applying various solutions. if any solution works will post it here as well.
@drelaptop looking for your advice as well
https://discuss.cocos2d-x.org/t/cocos2dx-v3-17-prebuilt-mk-is-not-generated/42670/9?u=drelaptop
@aqeeliqbal above is the example, it include both Android.mk you can refer to.
yes followed exactly this thread. but not working. Cant set the paths right i guess.