# Windows Configuration

Here are examples of different Windows configurations for building for different plaforms.

Please make sure you have compelted the Quick Start Guide, otherwise some steps may fail.

# PC Builds

In our PC example we have used Visual Studio 2017 which is automatically setup when creating a template c++ project, see our Quick Start Guide. You can find the Visual Studio project files under com.company.cocos/proj.win32/...

# Visual Studio 2017 Settings

  1. Start by right clicking the com.company.cocos/proj.win32/com.company.cocos.sln > Open with > Visual Studio 2017
  2. Right click on your Visual Studio Project in the Solution Explorer and select Properties
  3. Navigate to C/C++ > General and in the Additional Include Directories section add the following entry:..\Frameplay\
  4. Navigate to Linker > General and in the Additional Library Directories section add the following entry:..\Frameplay\Native\Platforms\Windows\Win32\
  5. Navigate to Linker > Input and under the Additional Dependencies section add the following entry:FrameplayNative.lib
  6. The FrameplayNative.dll must be copied over to your build output directory. Use a Post Build Event by navigating to Build Events > Post-Build Event and under the Command Line section add the following entry: copy /Y "..\Frameplay\Native\Platforms\Windows\Win32\FrameplayNative.dll" "$(OutDir)\FrameplayNative.dll"

# Build Win32

You should now be able to build in Visual Studio 2017 and see the template project open up, displaying a handful of mock advertisements. You can also build by running the following commands. Successful builds will be located in com.company.cocos/bin/debug/win32/...

cd ./com.company.cocos
cocos compile -p win32 -m debug

# Android Builds

In our Android example we have used CMake to build our Android apk. CMake is automatically setup when creating a template c++ project, see our Quick Start Guide. You can find the CMakeLists.txt in the root of the project com.company.cocos/CMakeLists.txt

# CMAKE Settings

  1. Open the CMakeLists.txt file in the project root directory
  2. Add Frameplay/ to the target_include_directories
target_include_directories(${APP_NAME}
		PRIVATE Frameplay/
)
  1. Include the libFrameplayNative.so and libc--_shared.so libraries from Frameplay/Native/Platforms/Android/${ANDROID_ABI} folder
set(FRAMEPLAY_ANDROID_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Frameplay/Native/Platforms/Android/${ANDROID_ABI}/)
add_library(libFrameplayNative SHARED IMPORTED)
set_target_properties(libFrameplayNative PROPERTIES IMPORTED_LOCATION ${FRAMEPLAY_ANDROID_LIB_PATH}libFrameplayNative.so)
add_library(libc--_shared SHARED IMPORTED GLOBAL)
set_target_properties(libc--_shared PROPERTIES IMPORTED_LOCATION ${FRAMEPLAY_ANDROID_LIB_PATH}libc--_shared.so)
  1. Link the libraries to your app
target_link_libraries(${APP_NAME} <your other libraries> libFrameplayNative libc++_shared)
  1. Add a custom command to copy the files from the lib directory into the build output directory.
add_custom_command
(
  TARGET ${APP_NAME} PRE_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy_directory
  ${FRAMEPLAY_ANDROID_LIB_PATH} $<TARGET_FILE_DIR:${APP_NAME}>
)

# Android Google AD_ID

For Google AD_ID to work you will need to complete the following.

  1. In your cocos project folder go to com.company.cocos\proj.android\app

  2. open build.gradle under dependencies include: implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':libcocos2dx')
    implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
}

Note: If your application is targeting Android 13 (API Level 33) or above, you will need to include this permission into AndroidManifest.xml located in com.company.cocos\proj.android\app

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

More information can be found here. (opens new window)

# Build Android

You should now be able to build by running the following commands. Successful builds will be located in com.company.cocos/bin/debug/android/...

cd ./com.company.cocos
cocos compile -p android -m debug
Last Updated: 10/19/2022, 10:00:52 PM