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

#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:


#97

@piotrros After work around with 3.17 I find the way to compile android with prebuilt libs.

  • Copy all prebuilt-mk folder in 3.16 to 3.17.
  • In 3.17 Box2D generate prebuilt libs in it owned folder not in root. I change the path from LOCAL_SRC_FILES := …/…/…/prebuilt/android/$(TARGET_ARCH_ABI)/libbox2d.a to LOCAL_SRC_FILES := …/prebuilt/android/$(TARGET_ARCH_ABI)/libbox2d.a

Those steps above let me compile android successful with prebuilt libs in 3.17.
Cheer.


#98

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:

https://pastebin.com/HVcgFqzZ

As you can see it pretty much cannot find anything :smiley:


#99

I can’t help you solve your problem with error logs. But here are my steps from Generate prebuilt libs and config:

Environment:

  • java version “1.8.0_172”
  • NDK r16-b
  • Latest Android SDK update with Android studio.

Generate prebuilt libs steps:

  • Change these files in cocos/platform/android:

    • ControllerManualAdapter/AndroidManifest.xml ->
    • ControllerManualAdapter/project.propeties -> target=android-27
    • java/AndroidManifest.xml ->
    • java/project.propeties -> target=android-27
  • Open Cocos2dx/build/cocos2d_libs.xcodeproj

    • Set build architect only to NO
    • Set latest target SDK
    • Add valid architect arm64 armv7 armv7s
  • Run cocos gen-libs -m debug -c

  • After gen-libs finished, copy all prebuilt-mk folder from cocos2dx 3.16 to cocos2dx 3.17

    • Cocos2dx/extenstions/prebuilt-mk
    • Cocos2dx/external/android-specific/pvmp3dec/prebuilt-mk
    • Cocos2dx/external/android-specific/tremolo/prebuilt-mk
    • Cocos2dx/external/Box2D/prebuilt-mk (change Android.mk file: LOCAL_SRC_FILES := …/prebuilt/android/$(TARGET_ARCH_ABI)/libbox2d.a)
    • Cocos2dx/external/flatbuffers/prebuilt-mk
    • Cocos2dx/external/recast/prebuilt-mk
    • Cocos2dx/cocos/prebuilt-mk
    • Cocos2dx/cocos/3d/prebuilt-mk
    • Cocos2dx/cocos/network/prebuilt-mk
    • Cocos2dx/cocos/ui/prebuilt-mk
    • Cocos2dx/cocos/platform/android/prebuilt-mk
    • Cocos2dx/cocos/audio/android/prebuilt-mk
    • Cocos2dx/cocos/editor-support/cocosbuilder/prebuilt-mk
    • Cocos2dx/cocos/editor-support/cocostudio/prebuilt-mk
    • Cocos2dx/cocos/editor-support/spine/prebuilt-mk

Config for Cpp Project Template:

  • Android : folder pro.android
    • Edit settings.gradle :
      include ‘:libcocos2dx’
      project(’:libcocos2dx’).projectDir = new File(’/Users/macos/Library/Cocos2dx/cocos/platform/android/libcocos2dx’)
      include ‘:HelloCpp’
      project(’:HelloCpp’).projectDir = new File(settingsDir, ‘app’)
    • Edit gradle.properties
      PROP_MIN_SDK_VERSION=16
    • Edit app/jni/Android.mk
      $(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)

      include $(BUILD_SHARED_LIBRARY)
      $(call import-module,./prebuilt-mk)

Cocos2dx v3.17 prebuilt-mk is not generated
#101

Thanks for help, but it didn’t help :frowning: 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


#102

is there any proper guide how to generate prebuilt libs and integrate them in Android Studio project?
cocos2d-x ver 3.17


#103

I would consider moving away from the prebuilt libraries. We plan to discontinue support for them.