Can't see any .so file in my jnilibs

Can't see any .so file in my jnilibs
0

Hello,
I’m trying to build android game with cocos latest stable version which i downloaded from official site as well i follow the steps required to setup path and compile it.

i done the developing side and when i try to compile android studio build it build successfully but there is no .so file for lib in my 32bit or 64bit folders.

i’m using android studio latest 3.4.1 version and ndk r20 cocos2dx3.17.2

When i compile it with cocos compile -p android --android-studio get following message

BUILD SUCCESSFUL in 10s
54 actionable tasks: 5 executed, 49 up-to-date
Move apk to /Users/XXX/Desktop/cocos2d-x-3.17.2/TempCocosProjects/MyGame/bin/debug/android
Build succeed.

But when i check jniLibs there is no any .so files

1 Like

I’m not really an android developer, but why would you be expecting a .so when you built an .apk?

because build is successful but i can;t run my game on android device

but you built an .apk why are you looking for a .so? libs is not where .apk is moved to after building.

Game is crashed with class not found exception i mean here .so file not found exception while my code reach the line system.loadlibrary(“MyGame”);

Again, you built an .apk, libs is not where you find that.

look at logcat

Show us more info.

Tell us which version of Cocos2d-x, which NDK version, etc, etc, etc. More info == easier to help. Just saying your game crashed isn’t useful to digging deeper.

Hey sorry for inconvenience but currently i switched to cmake build. and i face below error

 Build command failed.
  Error while executing process /Users/ArmoredTechnoSolution/Desktop/Armored/Android_Software/android-sdks/cmake/3.10.2.4988404/bin/cmake with arguments {--build /Users/ArmoredTechnoSolution/Desktop/cocos2d-x-3.17.2/NEW_PROJECTS_DIR/MyGame/proj.android/app/.externalNativeBuild/cmake/debug/x86 --target MyGame}
  [1/1] Linking CXX shared library ../../../../build/intermediates/cmake/debug/obj/x86/libMyGame.so
  FAILED: ../../../../build/intermediates/cmake/debug/obj/x86/libMyGame.so 
  : && /Users/ArmoredTechnoSolution/Desktop/Armored/Android_Software/android-sdks/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=i686-none-linux-android16 --gcc-toolchain=/Users/ArmoredTechnoSolution/Desktop/Armored/Android_Software/android-sdks/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64 --sysroot=/Users/ArmoredTechnoSolution/Desktop/Armored/Android_Software/android-sdks/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -mstackrealign -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security  -frtti -fexceptions -fsigned-char -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libMyGame.so -o ../../../../build/intermediates/cmake/debug/obj/x86/libMyGame.so CMakeFiles/MyGame.dir/Classes/AppDelegate.cpp.o CMakeFiles/MyGame.dir/Classes/HelloWorldScene.cpp.o CMakeFiles/MyGame.dir/proj.android/app/jni/hellocpp/main.cpp.o  -Wl,--whole-archive engine/cocos/platform/libcpp_android_spec.a -Wl,--no-whole-archive lib/libcocos2d.a lib/libexternal.a ../../../../../../cocos2d/external/Box2D/prebuilt/android/x86/libbox2d.a ../../../../../../cocos2d/external/chipmunk/prebuilt/android/x86/libchipmunk.a ../../../../../../cocos2d/external/freetype2/prebuilt/android/x86/libfreetype.a lib/libext_recast.a ../../../../../../cocos2d/external/jpeg/prebuilt/android/x86/libjpeg.a ../../../../../../cocos2d/external/webp/prebuilt/android/x86/libwebp.a ../../../../../../cocos2d/external/bullet/prebuilt/android/x86/libLinearMath.a ../../../../../../cocos2d/external/bullet/prebuilt/android/x86/libBulletDynamics.a ../../../../../../cocos2d/external/bullet/prebuilt/android/x86/libBulletCollision.a ../../../../../../cocos2d/external/bullet/prebuilt/android/x86/libLinearMath.a ../../../../../../cocos2d/external/bullet/prebuilt/android/x86/libBulletMultiThreaded.a ../../../../../../cocos2d/external/bullet/prebuilt/android/x86/libMiniCL.a ../../../../../../cocos2d/external/tiff/prebuilt/android/x86/libtiff.a ../../../../../../cocos2d/external/websockets/prebuilt/android/x86/libwebsockets.a ../../../../../../cocos2d/external/uv/prebuilt/android/x86/libuv_a.a ../../../../../../cocos2d/external/openssl/prebuilt/android/x86/libssl.a ../../../../../../cocos2d/external/openssl/prebuilt/android/x86/libcrypto.a lib/libext_tinyxml2.a lib/libext_xxhash.a lib/libext_xxtea.a lib/libext_clipper.a lib/libext_edtaa3func.a lib/libext_convertUTF.a lib/libext_poly2tri.a lib/libext_md5.a ../../../../../../cocos2d/external/curl/prebuilt/android/x86/libcurl.a ../../../../../../cocos2d/external/png/prebuilt/android/x86/libpng.a engine/external/android-specific/cpufeatures/libext_cpufeatures.a -ldl lib/libext_pvmp3dec.a lib/libext_tremolo.a ../../../../../../cocos2d/external/zlib/prebuilt/android/x86/libz.a lib/libext_unzip.a -lGLESv2 -lEGL -llog -landroid -lOpenSLES -latomic -lm && :
  ../../../../../../Classes/HelloWorldScene.cpp:222: error: undefined reference to 'AdmobHelper::exitDialog()'
  ../../../../../../Classes/HelloWorldScene.cpp:282: error: undefined reference to 'AdmobHelper::getScale_View()'
  ../../../../../../Classes/Baby_setting_panel.h:18: error: undefined reference to 'vtable for Baby_setting_panel'
  /Users/ArmoredTechnoSolution/Desktop/Armored/Android_Software/android-sdks/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: the vtable symbol may be undefined because the class is missing its key function
  ../../../../../../Classes/LanguageSelection.h:19: error: undefined reference to 'vtable for LanguageSelection'
  /Users/ArmoredTechnoSolution/Desktop/Armored/Android_Software/android-sdks/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: the vtable symbol may be undefined because the class is missing its key function
  clang++: error: linker command failed with exit code 1 (use -v to see invocation)
  ninja: build stopped: subcommand failed.

I’m using cocos2d-x-3.17.2 and android studio 3.4.1NDK r20

Let me know which things i need to change in cMake

#/****************************************************************************
# Copyright (c) 2013-2014 cocos2d-x.org
# Copyright (c) 2015-2017 Chukong Technologies Inc.
#
# http://www.cocos2d-x.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ****************************************************************************/

cmake_minimum_required(VERSION 3.6)

set(APP_NAME MyGame)

project(${APP_NAME})

set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)
set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/)

include(CocosBuildSet)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)

# record sources, headers, resources...
set(GAME_SOURCE)
set(GAME_HEADER)

set(GAME_RES_FOLDER
    "${CMAKE_CURRENT_SOURCE_DIR}/Resources"
    )
if(APPLE OR WINDOWS)
    cocos_mark_multi_resources(common_res_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
endif()

# add cross-platforms source files and header files 
list(APPEND GAME_SOURCE
     Classes/AppDelegate.cpp
     Classes/HelloWorldScene.cpp

     )
list(APPEND GAME_HEADER
     Classes/AppDelegate.h
     Classes/HelloWorldScene.h

     )

if(ANDROID)
    # change APP_NAME to the share library name for Android, it's value depend on AndroidManifest.xml
    set(APP_NAME MyGame)
    list(APPEND GAME_SOURCE
         proj.android/app/jni/hellocpp/main.cpp
         )
elseif(LINUX)
    list(APPEND GAME_SOURCE
         proj.linux/main.cpp
         )
elseif(WINDOWS)
    list(APPEND GAME_HEADER
         proj.win32/main.h
         proj.win32/resource.h
         )
    list(APPEND GAME_SOURCE
         proj.win32/main.cpp
         proj.win32/game.rc
         ${common_res_files}
         )
elseif(APPLE)
    if(IOS)
        list(APPEND GAME_HEADER
             proj.ios_mac/ios/AppController.h
             proj.ios_mac/ios/RootViewController.h
             )
        set(APP_UI_RES
            proj.ios_mac/ios/LaunchScreen.storyboard
            proj.ios_mac/ios/LaunchScreenBackground.png
            proj.ios_mac/ios/Images.xcassets
            )
        list(APPEND GAME_SOURCE
             proj.ios_mac/ios/main.m
             proj.ios_mac/ios/AppController.mm
             proj.ios_mac/ios/RootViewController.mm
             proj.ios_mac/ios/Prefix.pch
             ${APP_UI_RES}
             )
    elseif(MACOSX)
        set(APP_UI_RES
            proj.ios_mac/mac/Icon.icns
            proj.ios_mac/mac/Info.plist
            )
        list(APPEND GAME_SOURCE
             proj.ios_mac/mac/main.cpp
             proj.ios_mac/mac/Prefix.pch
             ${APP_UI_RES}
             )
    endif()
    list(APPEND GAME_SOURCE ${common_res_files})
endif()

# mark app complie info and libs info
set(all_code_files
    ${GAME_HEADER}
    ${GAME_SOURCE}
    )
if(NOT ANDROID)
    add_executable(${APP_NAME} ${all_code_files})
else()
    add_library(${APP_NAME} SHARED ${all_code_files})
    add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/platform/android ${ENGINE_BINARY_PATH}/cocos/platform)
    target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
endif()

target_link_libraries(${APP_NAME} cocos2d)
target_include_directories(${APP_NAME}
        PRIVATE Classes
        PRIVATE ${COCOS2DX_ROOT_PATH}/cocos/audio/include/
)

# mark app resources
setup_cocos_app_config(${APP_NAME})
if(APPLE)
    set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
    if(MACOSX)
        set_target_properties(${APP_NAME} PROPERTIES
                              MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist"
                              )
    elseif(IOS)
        cocos_pak_xcode(${APP_NAME} INFO_PLIST "iOSBundleInfo.plist.in")
        set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
        set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")
        set_xcode_property(${APP_NAME} CODE_SIGN_IDENTITY "iPhone Developer")
    endif()
elseif(WINDOWS)
    cocos_copy_target_dll(${APP_NAME})
endif()

if(LINUX OR WINDOWS)
    set(APP_RES_DIR "$<TARGET_FILE_DIR:${APP_NAME}>/Resources")
    cocos_copy_target_res(${APP_NAME} COPY_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
endif()

At a minimum you need to all any source and headers here. thus vtable issues.

Hello ,
Now my cMake is look like

add cross-platforms source files and header files

list(APPEND GAME_SOURCE
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
Classes/AdmobHelper.cpp
Classes/Baby_setting_panel.cpp
Classes/boy_dressup_screen_playarea.cpp
Classes/dressup_screen_playarea.cpp
Classes/LanguageSelection.cpp
Classes/legspa_screen_playarea.cpp
Classes/level_screen.cpp
Classes/Loading_Screen.cpp
Classes/makeup_screen_playarea.cpp
Classes/photo_view_playarea.cpp
Classes/puzzle_playarea.cpp
Classes/Rate_Us_Popup_screen.cpp
Classes/Setting_Playarea.cpp
Classes/spa_screen_playarea.cpp

Classes/SonarCocosHelperCPP/SonarFrameworks
)
list(APPEND GAME_HEADER
Classes/AppDelegate.h
Classes/HelloWorldScene.h
Classes/AdmobHelper.hpp
Classes/Baby_setting_panel.hpp
Classes/boy_dressup_screen_playarea.hpp
Classes/dressup_screen_playarea.hpp
Classes/GZCommon.h
Classes/Header.h
Classes/LanguageSelection.hpp
Classes/legspa_screen_playarea.hpp
Classes/level_screen.hpp
Classes/Loading_Screen.hpp
Classes/makeup_screen_playarea.hpp
Classes/photo_view_playarea.hpp
Classes/puzzle_playarea.hpp
Classes/Rate_Us_Popup_screen.hpp
Classes/Setting_Playarea.h
Classes/spa_screen_playarea.hpp

Classes/SonarCocosHelperCPP/BannerViewController.h
Classes/SonarCocosHelperCPP/InterstitialViewController.h
Classes/SonarCocosHelperCPP/IOSCPPHelper.h
Classes/SonarCocosHelperCPP/IOSHelper.h
Classes/SonarCocosHelperCPP/IOSResults.h
Classes/SonarCocosHelperCPP/SCHDefinitions.h
Classes/SonarCocosHelperCPP/SCHSettings.h
Classes/SonarCocosHelperCPP/SonarFrameworks.h

Classes/APPLOVIN_ADAPTER/AppLovinCustomEventInter.h
Classes/APPLOVIN_ADAPTER/GADMAdapterAppLovinRewardBasedVideoAd.h

 )

And i get Following error

]== “CMake Server” ==]

CMake Error at /Users/ArmoredTechnoSolution/Desktop/cocos2d-x-3.17.2/NEW_PROJECTS_DIR/MyGame/CMakeLists.txt:167 (add_library):
Cannot find source file:

Classes/AdmobHelper.hpp

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx

Need to add .hpp files too in header section or i just have to add .h files ?

Thank lot for quick response :slight_smile: I tried with also but same issue i face but let me try once again by adding all my class and header files in make file may be i forgot to delete build folder

Please contact Sonar for help if you are using their frameworks.

and I cant tell you to use .h or .hpp. Just use what the extension is. Also, make sure your paths inside Classes are correct.

Hi,
But error is here

CMake Error at /Users/ArmoredTechnoSolution/Desktop/cocos2d-x-3.17.2/NEW_PROJECTS_DIR/MyGame/CMakeLists.txt:167 (add_library):
Cannot find source file:

Classes/AdmobHelper.hpp

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx

Well go look at AdmobHelper and see what the extension is. Post a picture of your Classes folder with any folders expanded.

Yes there is an issue with cmake i request to close this here :slight_smile: Thanks a lot for your help , one more question in my mind is is there any way to dynamically add all my cpp and header files in cMake ?

Sure, you can always write a script to do this. Look up sed, awk, and just make an array of the file names found in Classes then use sed to replace the contents in your CMakeLists with your new content.

However, what if your classes folder has source and headers that are used for your Android build, but also files for other platforms. You have no way to distinguish that unless you have sub-directories in Classes for platform specific files.

@slackmoehrle Thanks for your perfect guidance i’ll search about sed,awk and done this as per my requirement :slight_smile:

@slackmoehrle i want to save screenshot of cocos2dx3.17 game in my android device but i can’t can you help me to achieve this? https://stackoverflow.com/q/56221018/3514144 any help will much appreciated :slight_smile:

I don’t follow exactly.

You have a cocos2d-x game running on android.

You want to take a screenshot of the game and save it to your photos?

Or

You want tor player to take a screenshot from within your game and save it to photos?

Or

You want to save a picture of your running scene and save it to photos