목차 |
---|
...
1.2.1.
...
Installation Environment
IDE: Android Studio
JDK: JDK 8이상
Android SDK: Android 14 (API 34)
OS : Android 6.0, API 23 이상 지원 API 23 or higher
Use Gradle Version 6.1.1 사용
1.2.2. SDK
...
Environment Setup
1.2.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' // Configuration for Performance Monitoring 을 위한 설정 classpath 'com.google.firebase:perf-plugin:1.2.0' // Add the Crashlytics Gradle plugin. classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0' } } 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' } } } |
...
코드 블럭 |
---|
# Project-wide Gradle settings. org.gradle.jvmargs=-Xmx4608M KAKAO_GAME_SDK_VERSION=4.0.0 # Add 아래 2개the following 설정two 추가settings android.useAndroidX=true android.enableJetifier=true |
1.2.2.3. build.gradle(app level)
적용한 application 의 In the build.gradle 파일에 아래와 같이 필요한 모듈을 선택적으로 설정합니다.
gradle 3.0 미만 버전을 사용하여 'implementation' 을 사용할 수 없는 개발사에서는 'compile'을 사용하시면 됩니다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 { ... // JavaRequired 8to 언어use 기능을Java 사용하기8 위해language 필요features compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } // ----- FirebaseAdd 를settings 사용하기for 위한using 설정Firebase 추가 시작 ----- // CrashlyticsConfiguration 을for 사용하기using 위한Crashlytics 설정 apply plugin: 'com.google.firebase.crashlytics' // Configuration for Performance Monitoring 을 위한 설정 apply plugin: 'com.google.firebase.firebase-perf' // ----- FirebaseEnd 를of 사용하기Firebase 위한 설정 추가 끝 settings ----- ... dependencies { // 게스트Required 인증을for 사용하는games 게임에서using guest 필요authentication. implementation "com.kakaogame.publishing:idp_device:$KAKAO_GAME_SDK_VERSION" // 페이스북Required for 인증을games 사용하는using 게임에서Facebook 필요authentication. implementation "com.kakaogame.publishing:idp_facebook:$KAKAO_GAME_SDK_VERSION" // 구글게임 인증을 사용하는 게임에서 필요Required for games using Google Game authentication. implementation "com.kakaogame.publishing:idp_googlegame:$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 for 인증을games 사용하는using 게임에서Twitter 필요authentication. implementation "com.kakaogame.publishing:idp_twitter:$KAKAO_GAME_SDK_VERSION" // 게임SDK의Required 주요to 기능을use 사용하기the 위해서main 필요.features of the Game SDK. implementation "com.kakaogame.publishing:gamesdk:$KAKAO_GAME_SDK_VERSION" // Required for games using Firebase FCM (Push), Analytics, Crashlytics, Performance Monitoring 을 사용하는 게임에서 필요. implementation "com.kakaogame.publishing:firebase:$KAKAO_GAME_SDK_VERSION" // 웹상점 기능을 사용하기 위해서 필요Required to use the web store feature. implementation "com.kakaogame.publishing:kakaogame_addon:$KAKAO_GAME_SDK_VERSION" // Required to 보안서비스use 기능을the 사용하기security 위해서service 필요feature. implementation "com.kakaogame.publishing:security:$KAKAO_GAME_SDK_VERSION" // 결제Required to 기능을use 사용하기the 위해서payment 필요feature. implementation "com.kakaogame.publishing:payment:$KAKAO_GAME_SDK_VERSION" } apply plugin: 'com.google.gms.google-services' // Google Services plugin |
1.2.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 |
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 | |
security | com.google.android.material:material:1.6.1 | |
payment | com.android.billingclient:billing:6.0.1 | |
4.4.0 | gamesdk | com.google.android.gms:play-services-ads-identifier:18.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 | |
security | com.google.android.material:material:1.6.1 | |
payment | com.android.billingclient:billing:6.0.1 | |
firebase | com.google.firebase:firebase-bom:32.8.1 |
만약 게임에서 위 라이브러리와 dependencies가 겹치는 외부 라이브러리를 사용하는 경우 아래와 같이 해당 링크를 제거하여 버전이 높은 쪽으로 사용할 수 있습니다 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)
|
...
|
Below is an example of changing the Facebook SDK version to the desired version in the game.
build.gradle(app level)
|
Crashlytics를 사용하지 않는 개발사에서는 아래와 같이 제거하실 수 있습니다If your development team does not use Crashlytics, you can remove it as shown below.
build.gradle(app level)
|
1.2.3.
...
IDP Authentication Information Setup
1.2.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 에 아래 리소스 파일 추가 및 value 설정합니다xml.
"카카오앱키"값은 발급 받은 값으로 변경이 필요합니다The value for "Kakao App Key" needs to be replaced with the issued key.
res/values/kakao_game_kakao_auth.xml
|
1.2.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 에 아래 리소스 파일 추가 및 value 설정합니다.
"페이스북앱키"값은 발급 받은 값으로 변경 필요합니다.
"페이스북 클라이언트 토큰"값은 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
|
1.2.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 에 아래 리소스 파일 추가 및 value 설정합니다.
"구글앱아이디"값과 "구글웹클라이언트아이디"값은 발급 받은 값으로 변경 필요합니다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
|
1.2.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 에 아래 리소스 파일 추가 및 value 설정합니다.
"SIWA클라이언트"값은 애플에서 발급 받은 값으로 변경 필요합니다The value for "SIWA Client ID" needs to be replaced with the issued key from Apple.
res/values/kakao_game_siwa_auth.xml
|
1.2.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 에 아래 리소스 파일 추가 및 value 설정합니다.
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
|
1.2.4. AndroidManifest.xml
...
File Configuration
The AndroidManifest.xml file of the game app must be configured with the following settings.
1.2.4.1.
...
Common Settings
Set the minimum supported SDK version to 23 or higher
android:minSdkVersion="23"
SDK 타겟 버전을 31 으로 설정합니다.
android:exported 명시적 선언 추가
SDK 에서는 아래 퍼미션들을 공통으로 사용합니다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
다중 화면 처리를 위한 설정을 추가합니다.
안드로이드 폰의 화면 분할 및 폴더블 폰에 대응하기 위해서 application 설정에 아래와 같이 추가합니다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"
각 추가되는 Activity 설정에 아래와 같이 추가합니다Add the following to each added Activity.
android:configChanges="orientation|screenSize|keyboard|screenLayout|screenSize|smallestScreenSize"
API 23 이상에서는 앱이 일반 텍스트 HTTP와 같은 일반 텍스트 네트워크 트래픽을 사용하는지 여부를 설정할 수 있습니다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 추가
아래와 같이 게임의 메인 Activity 에 intent filter 설정을 해주어야 합니다.
scheme은The main Activity of the game should include the following intent filter settings.
The scheme is composed of "kakaogame" + 앱아이디 로 구성 됩니다.(예를들어 앱ID가 123456이면 scheme 값은 the app ID. (For example, if the app ID is 123456, the scheme value will be "kakaogame123456" 이 됩니다.)
AndroidManifest.xml (공통 설정Common Settings)
|
1.2.4.2.
...
메인 Activity에 아래 intent filter 선언이 추가 되어야 합니다.
...
AuthCodeHandlerActivity 선언과 intent filter 선언이 필요합니다.
...
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)
|
1.2.4.3.
...
SignInHubActivity 선언이 추가 되어야 합니다.
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 메타 데이터 선언이 추가 되어야 합니다ID must be added.
APP_ID에 숫자를 하드코딩하면 인증에 실패합니다. 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)
|
1.2.4.4.
...
FacebookActivity 선언이 추가 되어야 합니다.
Facebook Authentication Configuration
The declaration for FacebookActivity must be added.
The meta-data declaration for com.facebook.sdk.ApplicationId 메타 데이터 선언이 추가 되어야 합니다ApplicationId must be added.
The meta-data declaration for com.facebook.sdk.ClientToken 메타 데이터 선언이 추가 되어야 합니다must be added.
AndroidManifest.xml (페이스북 인증 설정Facebook Authentication Configuration)
|
1.2.4.5.
...
Twitter Authentication Configuration
The declaration for TwitterOAuthActivity must be added.
AndroidManifest.xml (트위터 인증 설정Twitter Authentication Configuration)
|
1.2.4.6.
...
targetSdkVersion을 28 버전 이상으로 설정하고 http 통신을 사용하는 게임은 아래와 같은 설정이 필요합니다.
카카오 게임 SDK 내부에서는 http를 사용하지 않습니다. 개발사에서 cdn등 이슈로 http 콜이 필요한 경우에만 설정합니다.
http 콜이 필요한 도메인 설정
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 파일 생성하여 http 통신이 필요한 domain을 추가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 내 Application에 위에서 생성한 파일을 networkSecurityConfig 로 설정, set the file created above as networkSecurityConfig.
AndroidManifest.xml
코드 블럭 <application android:networkSecurityConfig="@xml/network_security_config">
1.2.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.
1.2.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.
1.2.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
keystore 등록해야할 키 해시는 아래와 같이 수행하여 구해야 합니다.
해당 샘플을 빌드한 머신에서 수행해야 합니다.
openssl 버전은 This must be executed on the machine where the sample was built.
Please use OpenSSL version 1.0.2 버전 혹은 그 이상것을 사용 해주시기 바랍니다or higher.
- 키 해시 오류가 날 경우, 아래의 방법으로도 시도해보시기 바랍니다
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
The key hash that needs to be registered in the keystore should be obtained by performing the following command.
코드 블럭 |
---|
keytool -exportcert -alias androiddebugkey -keystore {debug_keystore_path} -storepass android -keypass android | openssl sha1 -binary | openssl base64 |
위 방법은 리눅스에서는 정상 동작을 보증하나, 윈도우즈 환경에서는 제대로 값을 얻지 못할 수도 있습니다.
[debug_keystore_path]
OS X와 리눅스 : 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와 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 아래에 존재합니다.openssl : Windows의 경우는 다운 받아 설치합니다.
For Windows, you will need to download and install OpenSSL.
1.2.5.2.
...
Obtaining the Release Key Hash
|
---|
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> 오류를 받는다면 아래와 같이 정상적인 키 해시를 사용하고 있는지 확인하실 수 있습니다.
게임에서 사용하는 MainActivity 클래스에서 onCreate()를 임시로 아래와 같이 변경합니다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(); } }
위 코드를 실행시켜 Logcat 출력에 다음과 같이 표시된 메시지에서 키 해시를 확인합니다Run the above code and check the key hash from the message displayed in the Logcat output as follows.
1.2.6.
...
Build Verification
Verify that the project builds successfully.