메타 데이터의 끝으로 건너뛰기
메타 데이터의 시작으로 이동

You are viewing an old version of this content. View the current version.

현재와 비교 View Version History

« 이전 버전 7 다음 »


1. Installation Environment

  • IDE: Android Studio

  • JDK: JDK 8 or higher

  • Android SDK: Android 14 (API 34)

  • OS : Android 6.0, API 23 or higher

  • Use Gradle Version 6.1.1

2. SDK Environment Setup

2.1. build.gradle(project level)

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        // Requires at least version 3.1.2
        classpath 'com.google.gms:google-services:4.3.3'
    }
}
  
allprojects {
    repositories {
        google()
        mavenCentral()
        
        maven {
            url 'https://devrepo.kakao.com/nexus/content/groups/public/'
            name 'kakao'
        }
        maven {
            url 'https://s3.ap-northeast-2.amazonaws.com/kakao-sdk-release/release/'
            name 'Kakaogames'
        }
    }
}

2.2. gradle.properties

# Project-wide Gradle settings.
org.gradle.jvmargs=-Xmx4608M
KAKAO_GAME_SDK_VERSION=4.0.0
  
# Add the following two settings
android.useAndroidX=true
android.enableJetifier=true

2.3. build.gradle(app level)

In the build.gradle file of the applied application, selectively configure the necessary modules as shown below.
For developers using a version of Gradle below 3.0 who cannot use 'implementation', 'compile' can be used instead.

apply plugin: 'com.android.application'
 
android {
    ...
  
    // Required to use Java 8 language features
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
...
  
dependencies {
    // Required for games using guest authentication.
    implementation "com.kakaogame.publishing:idp_device:$KAKAO_GAME_SDK_VERSION"
 
    // Required for games using Kakao authentication.
    implementation "com.kakaogame.publishing:idp_kakao:$KAKAO_GAME_SDK_VERSION"
 
    // Required for games using Apple authentication.
    implementation "com.kakaogame.publishing:idp_siwa:$KAKAO_GAME_SDK_VERSION"
 
    // Required to use the main features of the Game SDK.
    implementation "com.kakaogame.publishing:gamesdk:$KAKAO_GAME_SDK_VERSION"
}
  
apply plugin: 'com.google.gms.google-services'  // Google Services plugin

2.4. External Library Dependencies

The necessary libraries are set as dependencies with the versions listed below. These are automatically included when connecting to the Kakao Game SDK.

SDK version

Module

External Libraries

4.0.1

gamesdk

com.google.android.gms:play-services-ads-identifier:18.0.0
androidx.appcompat:appcompat:1.3.1
androidx.legacy:legacy-support-v4:1.0.0
androidx.core:core-ktx:1.6.0
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0
androidx.databinding:viewbinding:7.0.4
com.google.android.play:review:2.0.0
com.google.android.play:app-update:2.0.0
com.android.installreferrer:installreferrer:2.2
com.github.bumptech.glide:glide:4.10.0
androidx.cardview:cardview:1.0.0

idp_kakao

com.kakao.sdk:{module}:2.13.0

idp_facebook

com.facebook.android:facebook-android-sdk:14.1.1

idp_googlegame

com.google.android.gms:play-services-auth:20.6.0
com.google.android.gms:play-services-games-v2:17.0.0
androidx.annotation:annotation:1.0.0

security

com.google.android.material:material:1.6.1

payment

com.android.billingclient:billing:6.0.1
androidx.recyclerview:recyclerview:1.0.0

4.4.0

gamesdk

com.google.android.gms:play-services-ads-identifier:18.0.0
androidx.appcompat:appcompat:1.6.1
androidx.legacy:legacy-support-v4:1.0.0
androidx.core:core-ktx:1.10.0
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0
androidx.databinding:viewbinding:7.0.4
com.google.android.play:review:2.0.0
com.google.android.play:review-ktx:2.0.0
com.google.android.play:app-update:2.0.0
com.google.android.play:app-update-ktx:2.0.0
com.android.installreferrer:installreferrer:2.2
com.github.bumptech.glide:glide:4.10.0
androidx.cardview:cardview:1.0.0

idp_kakao

com.kakao.sdk:{module}:2.18.0

idp_facebook

com.facebook.android:facebook-android-sdk:14.1.1

idp_googlegame

com.google.android.gms:play-services-auth:20.6.0
com.google.android.gms:play-services-games-v2:17.0.0
androidx.annotation:annotation:1.0.0

security

com.google.android.material:material:1.6.1

payment

com.android.billingclient:billing:6.0.1
androidx.recyclerview:recyclerview:1.0.0

firebase

com.google.firebase:firebase-bom:32.8.1
com.google.firebase:firebase-analytics
com.google.firebase:firebase-perf
com.google.firebase:firebase-crashlytics
com.google.firebase:firebase-messaging

 If the game uses external libraries that overlap with the above libraries and dependencies, you can remove the conflicting links as shown below and use the higher version.

build.gradle(app level)

dependencies {
    ...
     implementation ('com.kakaogame:gamesdk:{KAKAO_SDK_VERSION}') {
        exclude group: 'com.google.android.gms', module: 'play-services-ads' // The library you want to remove
        exclude group: 'com.android.support' // You can also remove the entire group of libraries. This can be adjusted if there is a build error due to version mismatches in support libraries.
        ...
    }
}

 Below is an example of changing the Facebook SDK version to the desired version in the game.

build.gradle(app level)

dependencies {
    ...
    implementation ('com.kakaogame:idp_facebook:{KAKAO_SDK_VERSION}') {
        exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
    }
  
    implementation 'com.facebook.android:facebook-android-sdk:4.39.0'
}

If your development team does not use Crashlytics, you can remove it as shown below.

build.gradle(app level)

dependencies {
    ...
    implementation ("com.kakaogame:firebase:$KAKAO_GAME_SDK_VERSION") {
        exclude group: 'com.crashlytics.sdk.android', module: 'crashlytics'
    }
}

3. IDP Authentication Information Setup

3.1. Kakao Authentication Information Setup

Add the following resource file and set the values in src/main/res/values/kakao_game_kakao_auth.xml.

The value for "Kakao App Key" needs to be replaced with the issued key.

res/values/kakao_game_kakao_auth.xml

<?xml version="1.0" encoding="UTF-8"?>
 
<resources>
    <string name="kakao_app_key">[Kakao App Key]</string>
    <string name="kakao_scheme">kakao[Kakao App Key]</string>
    <string name="kakaotalk_host">kakaotalk</string>
    <string name="kakaolink_host">kakaolink</string>
    <string name="kakaostory_host">kakaostory</string>
</resources>

3.2. Facebook Authentication Information Setup

Add the following resource file and set the values in src/main/res/values/kakao_game_facebook_auth.xml.

The value for "Facebook App Key" needs to be replaced with the issued key.

The value for "Facebook Client Token" can be found at the following: ​https://kakaogames.atlassian.net/wiki/spaces/KS3GFP/pages/411861845/2.1#2.1.2.-%ED%8E%98%EC%9D%B4%EC%8A%A4%EB%B6%81-%EA%B0%9C%EB%B0%9C%EC%9E%90-%EC%84%BC%ED%84%B0(%ED%81%B4%EB%9D%BC%EC%9D%B4%EC%96%B8%ED%8A%B8-%ED%86%A0%ED%81%B0-%ED%99%95%EC%9D%B8)---SDK-3.15.0-%EC%9D%B4%EC%83%81-%EB%B2%84%EC%A0%84-%EC%A0%81%EC%9A%A9-%EC%8B%9C-%EC%84%A4%EC%A0%95-%ED%95%84%EC%9A%94

res/values/kakao_game_facebook_auth.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="facebook_app_id">[Facebook App Key]</string>
    <string name="facebook_client_token">[Facebook Client Token]</string>
    <!--
    The "public_profile" and "email" permissions are defined by default for Facebook authentication.
    If additional read permissions are required, add them to the item below.
    Publish permissions cannot be added.
    -->
    <string-array name="facebook_read_pemissions">
        <item></item>
    </string-array>
</resources>

3.3. Google Authentication Information Setup

Add the following resource file and set the values in src/main/res/values/kakao_game_google_auth.xml.

The values for "Google App ID" and "Google Web Client ID" need to be replaced with the issued keys.

res/values/kakao_game_google_auth.xml

<?xml version="1.0" encoding="utf-8"?>
 
<resources>
    <string name="kg_google_app_id">[Google App ID]</string>
    <string name="kg_google_web_app_client_id">[Google Web Client ID]</string>
</resources>

3.4. SigninWithApple Authentication Information Setup

Add the following resource file and set the values in src/main/res/values/kakao_game_siwa_auth.xml.

The value for "SIWA Client ID" needs to be replaced with the issued key from Apple.

res/values/kakao_game_siwa_auth.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="siwa_client_id">[SIWA Client ID]</string>
</resources>

3.5. Twitter Authentication Information Setup

Add the following resource file and set the values in src/main/res/values/kakao_game_twitter_auth.xml.

The values for "Twitter Consumer Key" and "Twitter Consumer Secret" need to be replaced with the issued keys from Twitter.

res/values/kakao_game_twitter_auth.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="twitter_consumer_key">[Twitter Consumer Key]</string>
    <string name="twitter_consumer_secret">[Twitter Consumer Secret]</string>
</resources>

4. AndroidManifest.xml File Configuration

The AndroidManifest.xml file of the game app must be configured with the following settings.

4.1. Common Settings

  • Set the minimum supported SDK version to 23 or higher

    • android:minSdkVersion="23"

  • Set the SDK target version to 31.

    • Explicit declaration for android:exported is required.

  • The SDK commonly uses the following permissions

    • android.permission.INTERNET

    • android.permission.ACCESS_NETWORK_STATE

  • Add settings for handling multiple screens.

    • To support screen splitting on Android phones and foldable phones, add the following to the application settings.

      • android:resizeableActivity="true"

    • Add the following to each added Activity.

      • android:configChanges="orientation|screenSize|keyboard|screenLayout|screenSize|smallestScreenSize"

  • For API 23 and above, you can specify whether the app uses cleartext network traffic, such as plain text HTTP.

    • android:usesCleartextTraffic="true"

  • Add URLScheme

    • The main Activity of the game should include the following intent filter settings.

      The scheme is composed of "kakaogame" + the app ID. (For example, if the app ID is 123456, the scheme value will be "kakaogame123456")

AndroidManifest.xml (Common Settings)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- KakaoGame SDK START -->
<uses-sdk
    android:minSdkVersion="23"
    android:targetSdkVersion="31" />
<!-- KakaoGame SDK END -->
 
<!-- KakaoGame SDK START -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- KakaoGame SDK END -->
 
<application
    android:usesCleartextTraffic="true"
    android:resizeableActivity="true">
    <!-- MainActivity START : Included only in the publishing guide: Start -->
    <activity android:name="com.companyname.MainActivity"
          android:configChanges="orientation|screenSize|keyboard|screenLayout|screenSize|smallestScreenSize"
          android:label="@string/app_name"
          android:launchMode="singleTask"
          android:screenOrientation="sensor"
          android:exported=”true” >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="kakaogame[App Id]" />
    </intent-filter>
    ...
    </activity>
    <!-- MainActivity END : Included only in the publishing guide: End -->
</application>
</manifest>

4.2. Kakao Authentication Configuration

  • The main Activity must include the following intent filter declaration.

  • You need to declare AuthCodeHandlerActivity and add its intent filter.

  • For Android 12, the exported attribute must be explicitly declared.

AndroidManifest.xml (Kakao Authentication Configuration)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
    <activity android:name=".MainActivity"
              android:exported=”true”>
        <!-- Kakao Auth START -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/kakao_scheme" android:host="@string/kakaolink_host" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/kakao_scheme" android:host="@string/kakaostory_host" />
        </intent-filter>
        <!-- Kakao Auth END -->
    </activity>
 
    <activity android:name="com.kakao.sdk.auth.AuthCodeHandlerActivity"
              android:exported=”true”>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:host="oauth" android:scheme="@string/kakao_scheme" />
        </intent-filter>
    </activity>
</application>
</manifest>

4.3. Google Authentication Configuration

  • The declaration for SignInHubActivity must be added.

  • The meta-data declarations for com.google.android.gms.version/com.google.android.gms.games.APP_ID must be added.

  • If you hardcode a number for APP_ID, authentication will fail. It should be written in the form of "@string/google_app_id".

AndroidManifest.xml (Google Authentication Configuration)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
 
<application>
<!-- Google Auth START -->
<activity
    android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
<meta-data
    android:name="com.google.android.gms.games.APP_ID"
    android:value="@string/google_app_id" />
<!-- Google Auth END -->
</application>
</manifest>

4.4. Facebook Authentication Configuration

  • The declaration for FacebookActivity must be added.

  • The meta-data declaration for com.facebook.sdk.ApplicationId must be added.

  • The meta-data declaration for com.facebook.sdk.ClientToken must be added.

AndroidManifest.xml (Facebook Authentication Configuration)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<!-- Facebook Auth START -->
<activity
    android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />
 
<meta-data
    android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id" />

<meta-data
    android:name="com.facebook.sdk.ClientToken"
    android:value="@string/facebook_client_token" />
<!-- Facebook Auth END -->
</application>
</manifest>

4.5. Twitter Authentication Configuration

  • The declaration for TwitterOAuthActivity must be added.

AndroidManifest.xml (Twitter Authentication Configuration)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<application>
<!-- Twiitter Auth Start -->
    <activity android:name="com.kakaogame.twitter.TwitterOAuthActivity"
        android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" />
<!-- Twitter Auth End -->
</application>
</manifest>

4.6. HTTP Usage Configuration

If targetSdkVersion is set to version 28 or higher and the game uses HTTP communication, the following configuration is necessary.

The Kakao Game SDK does not use HTTP internally. This setting is only needed if the developer requires HTTP calls for issues like CDN.

  • Setting the domain that requires HTTP calls

    • Create the res/xml/network_security_config.xml file and add the domain that requires HTTP communication.

      network_security_config.xml

      <?xml version="1.0" encoding="utf-8"?>
      <network-security-config>
          <domain-config cleartextTrafficPermitted="true">
              <!-- Add Your Http Domain -->
              <domain includeSubdomains="true">example.com</domain>
          </domain-config>
      </network-security-config>
      

    • In the Application section of the AndroidManifest.xml, set the file created above as networkSecurityConfig.

      AndroidManifest.xml

      <application
              android:networkSecurityConfig="@xml/network_security_config">
      

4.7. Game Supported Language Resources

If there are additional language packs in the library that are not supported by the game, and you want to remove them, you can delete the corresponding folder at the location below.

For example, if you want to remove the Japanese language settings, delete the KakaoGameSDK>res>values-ja folder.

5. Key Hash Verification and Registration Method

  • To build the app, you need to register the key hash of the build machine, and you can check the key hash using the following method.

    Obtain the debug key hash and release key hash according to the guide below and register them in the [Game Center > Game Management > Key Hash Registration] menu.

5.1. Obtaining the Debug Key Hash

  • When you install the Android SDK, a development certificate is stored in the debug.keystore file under the alias androiddebugkey. The method to verify the certificate is as follows. (Note: This is not the actual method to obtain the key hash.)

    keytool -exportcert -alias androiddebugkey -keystore {debug_keystore_path} -storepass android -keypass android
    
  • The key hash that needs to be registered in the keystore should be obtained by performing the following command.

    • This must be executed on the machine where the sample was built.

    • Please use OpenSSL version 1.0.2 or higher.

     keytool -exportcert -alias androiddebugkey -keystore {debug_keystore_path} -storepass android -keypass android | openssl sha1 -binary | openssl base64
    
  • The above method is guaranteed to work on Linux, but may not provide correct values in a Windows environment.

    • If you encounter key hash errors, try the following method as well.

    keytool -exportcert -alias androiddebugkey -keystore {debug_keystore_path} > ./debug.txt
    openssl sha1 -binary debug.txt > debug_sha.txt
    openssl base64 -in debug_sha.txt > debug_base64.txt
    

[debug_keystore_path]

  • OS X and Linux: You can check it under Eclipse "ADT > Preferences > Android > Build > Default debug keystore". (e.g., ~/.android/debug.keystore)

  • Windows: You can check it under Eclipse "Window > Preferences > Android > Build > Default debug keystore".

  • Windows Vista and Windows 7: (e.g., C:\Users\.android\debug.keystore)

  • Windows XP: (e.g., C:\Documents and Settings\.android\debug.keystore)

  • keytool is located under $JAVA_HOME/bin.

  • For Windows, you will need to download and install OpenSSL.

5.2. Obtaining the Release Key Hash

keytool -exportcert -alias [release_key_alias] -keystore [release_keystore_path] | openssl sha1 -binary | openssl base64
  • Checking for invalid android_key_hash Errors

    • If you continue to receive <com.kakao.util.exception.KakaoException: AUTHORIZATION_FAILED : invalid android_key_hash or ios_bundle_id or web_site_url> errors after registering the key hash in the Game Center, you can verify whether you are using the correct key hash as follows:

    • Temporarily modify the onCreate() method in the MainActivity class in the game as follows.

    • MainActivity

      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
           
          // Add code to print out the key hash
          try {
                  android.content.pm.Signature[] signatures;
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
                      PackageInfo packageInfo = getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNING_CERTIFICATES);
                      if (packageInfo == null
                              || packageInfo.signingInfo == null) {
                          Log.e("KeyHash:", "KeyHash is Null. ");
                      }
                      if(packageInfo.signingInfo.hasMultipleSigners()){
                          signatures = packageInfo.signingInfo.getApkContentsSigners();
                      } else {
                          signatures = packageInfo.signingInfo.getSigningCertificateHistory();
                      }
                  } else {
                      PackageInfo info = getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
                      signatures = info.signatures;
                  }
      
                  for (android.content.pm.Signature signature : signatures) {
                      MessageDigest md = MessageDigest.getInstance("SHA");
                      md.update(signature.toByteArray());
                      Log.e("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
                  }
              } catch (PackageManager.NameNotFoundException e) {
                  e.printStackTrace();
              } catch (NoSuchAlgorithmException e) {
                  e.printStackTrace();
              }
      }
      

      Run the above code and check the key hash from the message displayed in the Logcat output as follows.

6. Build Verification

Verify that the project builds successfully.

 

  • 레이블 없음

0 댓글

로그인 상태가 아닙니다. 변경하는 경우 익명으로 표기됩니다. 이미 계정이 있다면 로그인을 원하실 수 있습니다.