SDK Implementation - fan-ADN/nendSDK-cocos2d-x GitHub Wiki

Implementation for iOS

Follow nendSDK iOS Set Up Manual

  1. Add NendAd.embeddedframework folder in NendModule/NendSDK/iOS to Xcode's Project Navigator by drag & drop.
  2. Add the following framework to the project
  • AdSupport
  • Security
  • ImageIO
  • AVFoundation
  • CoreMedia
  • SystemConfiguration
  • WebKit
  1. Optionally add the following framework and enable more detailed information for ad delivery.
  • CoreLocation
  • CoreMotion
  • CoreTelephony

image

cocos2d-x module Implementation

Add NendModule/Common and NendModule/iOS file to the project.

2018-02-26 17 3816

Implementation for android

SDK Implementation

  1. Add the below code into your build.grade.
...
allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
}
  1. Select Import .JAR/.AAR Package from File > New > New Module... in the menu tab. image

  2. Select the aar file in NendModule/NendSDK/Android. The name given to Subproject name: will be the name of the build.gradle file, settings.gradle file, or nendSDK used in the procedure in 3.. image

  3. Select Project name of your app from File > Project Structure > Dependencies > Modules and select nendSDK imported with 3 Module Dependency from 2. in the menu. image

  4. If nendSDK added to 3. in build.gradle has been added as compile project, the embed of the aar file is complete. Also add following libraries to the project.

  1. Ultimately the installation of nendSDK is complete as follows.
    build.gradle
android {
    compileSdkVersion 28
    ...
}

...

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':libcocos2dx')
    implementation ('com.google.android.gms:play-services-ads-identifier:17.0.0') {
        exclude module: 'support-v4'
    }
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation project(path: ':nendSDK-5.2.0')
}

If you cannot use AndroidX, Use nendSDK cocos2d-x module version 2.4.0 and set as follows.

Cannot use AndroidX

build.gradle

android {
    compileSdkVersion 28
    ...
}

...

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':libcocos2dx')
    implementation('com.google.android.gms:play-services-ads-identifier:16.0.0') {
        exclude module: 'support-v4'
    }
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation project(':nendSDK-5.1.0')
}

  1. When location data is used in the application Can use location data in ads distribution by adding the following library to dependencies in build.gradle.
dependencies {
    ...
    implementation 'com.google.android.gms:play-services-location:17.0.0'
}
  1. Run Gradle

cocos2d-x module Implementation

Create net.nend.NendModule package as a project and add java source file which is in the NendModule/javaPackage.
※ Build will be done correctly even if the error comes up so please ignore the error alert.

image

Add file of Nend module (NendModule/Common and NendModule/Android) into the project Classes folder.

2018-02-26 17 4006 2018-02-26 17 4047

Add nend module source files and header files

The procedure differs depending on the setting of PROP_BUILD_TYPE in gradle.properties.

cmake

Open up your CMakeLists.txt in the project root directory and add the shown lines in below.

...
if(ANDROID)
    ...
    # Add the source file to `GAME_SOURCE`.
    file(GLOB_RECURSE NEND_MODULE_SOURCE RELATIVE ${CMAKE_SOURCE_DIR} CONFIGURE_DEPENDS "Classes/Common/*.cpp" "Classes/Android/*.cpp")
    list(APPEND GAME_SOURCE ${NEND_MODULE_SOURCE})
    # Add the header file to` GAME_HEADER`.
    file(GLOB_RECURSE NEND_MODULE_HEADER RELATIVE ${CMAKE_SOURCE_DIR} CONFIGURE_DEPENDS "Classes/Common/*.h"  "Classes/Android/*.h")
    list(APPEND GAME_HEADER ${NEND_MODULE_HEADER})
    ...
endif()

...

target_include_directories(${APP_NAME}
        ...
        # Add the paths of NendModule's `Common` and` Android` directories.
        PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Classes/Common/
        PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Classes/Android/
)
...
ndk-build

Add following code to LOCAL_SRC_FILE of jni/Android.mk.

../../../Classes/Common/NendNativeLabel.cpp \
../../../Classes/Common/NendNativeSprite.cpp \
../../../Classes/Common/NendNativeClippingNode.cpp \
../../../Classes/Common/NendNativeAdClient.cpp \
../../../Classes/Common/NendHttpHelper.cpp \
../../../Classes/Common/NendNativeAdLog.cpp \
../../../Classes/Common/NendNativeAdRender.cpp \
../../../Classes/Common/NendNativeAdBinder.cpp \
../../../Classes/Common/NendNativeAd.cpp \
../../../Classes/Common/NendLogger.cpp \
../../../Classes/Common/NendNativeImpressionTracker.cpp \
../../../Classes/Common/NendVideoAd.cpp \
../../../Classes/Android/NendModule.cpp \
../../../Classes/Android/NendIconModule.cpp \
../../../Classes/Android/NendInterstitialModule.cpp \
../../../Classes/Android/AndroidNativeAd.cpp \
../../../Classes/Android/AndroidNativeJNI.cpp \
../../../Classes/Android/AndroidNativeAdClient.cpp \
../../../Classes/Android/NendFullBoardAd.cpp \
../../../Classes/Android/NendAdJniUtils.cpp \
../../../Classes/Android/NendInterstitialVideoAd.cpp \
../../../Classes/Android/NendRewardedVideoAd.cpp \
../../../Classes/Android/NendUserFeature.cpp \
../../../Classes/Android/AndroidNendLogger.cpp

Add following code to LOCAL_C_INCLUDES of jni/Android.mk.

LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../Classes/Common
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../../Classes/Android
⚠️ **GitHub.com Fallback** ⚠️