Skip to main content

Setup

This page describes how to set up the AndApp SDK for C++.

warning

The sample code listed below may be out-of-date. Use the documentation and headers shipped with your SDK distribution as your primary reference.

From version 0.2.1 the file name of the AndAppSDK.lib static library has changed. Use the file named AndAppSDK_MD.lib or AndAppSDK_MT.lib depending on your build configuration.

SDK Distribution​

AndApp SDK for C++ is distributed as a statically linked library.

Visual Studio 2013 and Visual Studio 2015 32-bit build configurations are currently supported. The appropriate library should be selected based on your build settings, which can be found by opening your project's "Property Pages" and navigating to:

"Configuration Properties" --> "C/C++" --> "Code Generation" --> "Runtime Library"

The following 32-bit build configurations are available:

  • Visual Studio 2013
    • Multi-thread (/ MT)
      • ./lib/VS2013/Release/x86/AndAppSDK_MT.lib
    • Multi-thread debug (/ Mtd)
      • ./lib/VS2013/Debug/x86/AndAppSDK_MT.lib
    • Multi-threaded DLL (/ MD)
      • ./lib/VS2013/Release/x86/AndAppSDK_MD.lib
    • Multi-threaded debug DLL (/ MDd)
      • ./lib/VS2013/Debug/x86/AndAppSDK_MD.lib
  • Visual Studio 2015
    • Multi-thread (/ MT)
      • ./lib/VS2015/Release/x86/AndAppSDK_MT.lib
    • Multi-thread debug (/ Mtd)
      • ./lib/VS2015/Debug/x86/AndAppSDK_MT.lib
    • Multi-threaded DLL (/ MD)
      • ./lib/VS2015/Release/x86/AndAppSDK_MD.lib
    • Multi-threaded debug DLL (/ MDd)
      • ./lib/VS2015/Debug/x86/AndAppSDK_MD.lib

Importing the SDK​

  1. Copy the AndAppSDK directory to a location accessible by your project.
  2. Add the AndAppSDK\Include directory to your project's [Additional Include Directories].
    1. Navigate to [Configuration Properties] --> [C/C++] --> [General] -> [Additional Include Directories] and add AndAppSDK\Include
    2. For example, if you placed the AndAppSDK directory at the same level as your Visual Studio project file, you would add the line: $(ProjectDir)AndAppSDK\Include to [Additional Include Directories].
  3. Add the appropriate library to your project's linker dependencies. The library you add will be different, depending on the required runtime library. 
    1. If your IDE is Visual Studio 2013 and the configuration is Debug:
      1. Navigate to [Configuration Properties] --> [Linker] --> [Input] --> [Additional Dependencies] and add AndAppSDK\Lib\VS2013\Debug\x86\AndAppSDK_MD.lib or  AndAppSDK\Lib\VS2013\Debug\x86\AndAppSDK_MT.lib depending on your runtime library settings.
      2. For example, if you placed the AndAppSDK directory at the same level as your Visual Studio project file, you would add the line $(ProjectDir)\AndAppSDK\Lib\VS2013\Debug\x86\AndAppSDK_MD.lib or $(ProjectDir)\AndAppSDK\Lib\VS2013\Debug\x86\AndAppSDK_MT.lib to [Additional Dependencies].
    2. If your IDE is Visual Studio 2013 and the configuration is Release:
      1. Navigate to [Configuration Properties] --> [Linker] --> [Input] --> [Additional Dependencies] and add AndAppSDK\Lib\VS2013\Release\x86\AndAppSDK_MD.lib or  AndAppSDK\Lib\VS2013\Release\x86\AndAppSDK_MT.lib depending on your runtime library settings.
      2. For example, if you placed the AndAppSDK directory at the same level as your Visual Studio project file, you would add the line $(ProjectDir)\AndAppSDK\Lib\VS2013\Release\x86\AndAppSDK_MD.lib or $(ProjectDir)\AndAppSDK\Lib\VS2013\Release\x86\AndAppSDK_MT.lib to [Additional Dependencies].
    3. If your IDE is Visual Studio 2015 and the configuration is Debug:
      1. Navigate to [Configuration Properties] --> [Linker] --> [Input] --> [Additional Dependencies] and add AndAppSDK\Lib\VS2015\Debug\x86\AndAppSDK_MD.lib or  AndAppSDK\Lib\VS2015\Debug\x86\AndAppSDK_MT.lib depending on your runtime library settings.
      2. For example, if you placed the AndAppSDK directory at the same level as your Visual Studio project file, you would add the line $(ProjectDir)\AndAppSDK\Lib\VS2015\Debug\x86\AndAppSDK_MD.lib or $(ProjectDir)\AndAppSDK\Lib\VS2015\Debug\x86\AndAppSDK_MT.lib to [Additional Dependencies].
    4. If your IDE is Visual Studio 2015 and the configuration is Release:
      1. Navigate to [Configuration Properties] --> [Linker] --> [Input] --> [Additional Dependencies] and add AndAppSDK\Lib\VS2015\Release\x86\AndAppSDK_MD.lib or  AndAppSDK\Lib\VS2015\Release\x86\AndAppSDK_MT.lib depending on your runtime library settings.
      2. For example, if you placed the AndAppSDK directory at the same level as your Visual Studio project file, you would add the line $(ProjectDir)\AndAppSDK\Lib\VS2015\Release\x86\AndAppSDK_MD.lib or $(ProjectDir)\AndAppSDK\Lib\VS2015\Release\x86\AndAppSDK_MT.lib to [Additional Dependencies].
  4. #include "andapp/AndApp.h" after completing steps 1-3 listed above. This will pull in all the the headers needed to use the SDK.

Initializing the SDK​

Before utilizing the functions provided by AndApp SDK, you will need to initialize the subsystem.

Call AndApp::SDK::Initialize(...) to initialize AndApp SDK. This should be down as quickly after starting your application as possible.

The AndApp SDK initialization flow can be summarized as:

The order of the call, as shown in the following code,

  1. Call AndApp::SDK::IsInitialized() to confirm whether or not AndApp SDK has been initialized or not.
  2. Call std::unique_ptr<AndApp::ConfigBuilder> builder = AndApp::ConfigBuilder::Instance(); to create the AndApp SDK configuration builder.
  3. Call builder->SetClientId(...); to set your client identifier.
  4. Call builder->SetDisableLogging(...); to enable or disable logging. This should always be set to true for builds intended for production.
  5. Call AndApp::SDK::Initialize(...); passing the appropriate parameters.

Example:

#include "andapp/AndApp.h" // Please be sure to include the andapp/AndApp.h. It is not with a backslash. 
#include <functional> 
#include <string> 
  

int main(int argc, char *argv[]){
if (!AndApp::SDK::IsInitialized()) {
std::unique_ptr<AndApp::ConfigBuilder> builder = AndApp::ConfigBuilder::Instance();

std::string clientId = "XXXXXXXXXXXXXXXXXXX";
builder->SetClientId(clientId);
builder->SetDisableLogging(false);

AndApp::SDK::Initialize(std::move(builder), [](const AndApp::Error &error, const AndApp::LaunchOptions &launchOptions) {
if (error.GetCode() != 0) {
// initialization failure
return;
}
});
}

return 0;
}
 
warning

AndApp::SDK::Initialize should be called once and only once per process. Multiple calls will result in undefined behavior.

Persistence of game-specific user data​

AndApp creates a known directory for the persistence of game-specific user data. Games are recommended to store game-specific user data in this location.

method
description
static std::string AndApp::Storage::GetPersistentDataPath()Returns the path for persistent data storage
static std::string AndApp::Storage::GetTemporaryDataPath()Returns the path for temporary data storage

Uninstallation​

All files at and below the directory containing the game's entry-point executable as well as all data stored in the persistent data path will be deleted when the game is uninstalled. All games will be uninstalled if the AndApp Client is uninstalled.

Change log​

  • 2017/10/20
    • Added description of AndApp::Storage::GetTemporaryDataPath() method.
  • 2016/10/26
    • Added description of SetDisableLogging.
  • 2016/09/20
    • Support for MD and MT static libraries.Now that we have MD version and the MT version static library, it has been corrected.
  • 2016/09/02
    • Changed  Storage::PersistentDataPath () to Storage::GetPersistentDataPath ().
  • 2016/08/19
    • It added an item in the format in which SDK.
    • Added "Importing the SDK" section.
    • Lambda capture changed to [] from [=].
    • SetClientId(...) documentation.
    • Removed LoadFromFile(). Added Instance ().
    • Added SetClientId method.
    • AndApp::ConfigBuilder to be passed to the first argument of the Initialize has been fixed because it was std::unique_ptr AndApp::ConfigBuilder.
    • Initialize  passed to the first argument of  std::unique_ptrAndApp::ConfigBuilder because there was a need to pass in the std::move, it has been fixed.
  • 2016/08/18
    • Changed parameter of AndApp::ConfigBuilder::LoadFromFile() to take std::unique_ptrAndApp::ConfigBuilder.
  • 2016/07/28
    • Initial