Update: We need help testing v3.17 (it's only a few weeks away)

Update: We need help testing v3.17 (it's only a few weeks away)
0

#75

gen-libs works for me too, but I can’t build the app with them. Something in the structure changed, because prebuilt-mk directories are missing.


#76

Until now I successfully used them and it worked.


#77

@drelaptop do you know about this?


#79

@piotrros @BuildFailed

Same problem trouble me, why we only have a gen-libs to gen prebuilt libraries, but didn’t have a option to use them. for example --use-libs, we will easy to use them if existed that option.

So how to use the prebuilt libs? I think we have to create a Android.mk to add the prebuilt libs, and include engine header files. and then use it in Gradle, it’s same as using 3rd-party prebuilt libs, a common issue to use libs by Android.mk, not a special Cocos2d-x problem.

In other side, we support cmake for the android native build in coming 3.17 release, also GitHub v3 latest code, CMake build supply another way to generate libs, and use those libs, just enable/disable option, not need to do hard works. Refer to cmake/readme to know how to use it. the gradle configs is,

// prebuilt root must be defined as a directory which you have right to access or create if you use prebuilt
// set "-DGEN_COCOS_PREBUILT=ON" and "-DUSE_COCOS_PREBUILT=OFF" to generate prebuilt, like "cocos gen-libs"
// set "-DGEN_COCOS_PREBUILT=OFF" and "-DUSE_COCOS_PREBUILT=ON" to use prebuilt, like "--use-libs"
// default behavior is both OFF, neither gen-libs nor use-libs.
arguments "-DCOCOS_PREBUILT_ROOT=/Users/laptop/cocos-prebuilt"
arguments "-DGEN_COCOS_PREBUILT=OFF", "-DUSE_COCOS_PREBUILT=ON"

and please set PROP_BUILD_TYPE=cmake to enable cmake native build, refer to this in gradle.properties

# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=ndk-build

#81

you will have to rebuild pre-compiled libs if the source code of engine changes, I think not any better choice.

wonderful, using prebuilt isn’t necessary for using the engine.


#82

Some notes about Windows versions (win32 and win10):
(would be great to have it include in a next update)

on Win10 & Win32:

  • add Box2D libs from 3.15 in cocos2dx-3.17/external (for Win32 need to configure the lib for recent version of SDK and Visual studio, also setted as dll instead of static lib but not sure of what I do)
  • add in project .vcxproj: code “4068” in DisableSpecificWarnings (debugs & releases nodes) (to avoid pragma mark warnings)

on Win10:

  • get the proj.win10 back (for now I copy a directory from a cocos2dx-3.15 proj.win10 generated project)
  • remove all libbullet references in the yourproject.sln and App/yourproject.vcxproj files (seems that some ref are also in libcocos on Win32)

on Win32:

  • add “$(EngineRoot);” in the 2 AdditionalIncludeDirectories (debug & release) (to get rid of some cocos-ext include issues)

  • change project properties-> c/c++ -> Debug Information Format C7 compatible(/Z7)
    ie in vcxproj
    <DebugInformationFormat>OldStyle</DebugInformationFormat>
    for issues of kind “Internal Compiler Error: failed to write injected code block to PDB”

  • build-cfg.json is not supported, so could be deleted, in the .vcxproj file, use instead:
    xcopy “$(ProjectDir)…\Resources\your_path_one” “$(OutDir)” /D /E /I /F /Y
    xcopy “$(ProjectDir)…\Resources\your_path_two” “$(OutDir)” /D /E /I /F /Y

  • replace libcurl_impl.lib; by libcurl.lib; in release AdditionalDependencies in vcxproj


#83

Any way to not use the prebuilt external and build it our self like in 3.16


#84

You can use the source tree or run cocos gen-libs or do I not understand your question?


#85

@slackmoehrle Sorry, will try to explain more. I am using a highly modified box2d and now since 3.17 uses prebuilt box2d. How can I use mine? In 3.16 I will just replace box2d that’s in the external folder with mine and compile it. Now I can’t do that anymore.

Appreciate it if you can give some guidance.

Thanks!


#86

Android or iOS?


#87

Android. But does it matter? In 3.16 it works for both by replacing box2d in external folder.


#88

I think it does matter on how it is solved. iOS is easier. Android I think will require modifying some files.


#89

Another method, you can build your custom Box2d into prebuilt-libs and replace the default Box2d, if you select this way, you can refer to:


#90

@drelaptop Thank you!

@slackmoehrle do you know what files needed to be change to compile custom box2d?

By the way thank you for the help!


#91

I feel like you could add your library to one of the files like: Android.mk, Application.mk, etc.

@mozartalouis @mars3142 is this correct?


#92

Maybe another way if I bring in box2d as part of /Classes/box2d/ will it collide with the prebuilt box2d?


#93

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:

  1. Added
    PROP_BUILD_TYPE=cmake

in gradle.properties

  1. 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"
             }
    
         }
     }
    
  2. Copy-pasted CMakeLists.txt from a freshly generated new project as I haven’t got one in my project.


#94

Let me test this and also ask @drelaptop for thoughts


#95

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.


#96

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?. :worried: