목차 |
---|
...
1.2.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
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' } } } |
1.2.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 |
1.2.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 } } // ----- Add settings for using Firebase ----- // Configuration for using Crashlytics apply plugin: 'com.google.firebase.crashlytics' // Configuration for Performance Monitoring apply plugin: 'com.google.firebase.firebase-perf' // ----- End 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" // 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.
...
|
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.
...
|
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.
...
|
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.
...
|
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.
...
|
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.
...
|
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"
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")
...
|
1.2.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.
...
|
1.2.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".
...
|
1.2.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.
...
|
1.2.4.5. Twitter Authentication Configuration
The declaration for TwitterOAuthActivity must be added.
...
|
1.2.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.
...
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">
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
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
...
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.
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> 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.
1.2.6. Build Verification
Verify that the project builds successfully.
...