This document describes what you should do to integrate the Kakao SDK for Android (hereinafter referred to as 'Android SDK') into your web before leveraging the Kakao APIs.
To use Android SDK, you must register the Android platform in advance. Go to [My Application] > [Platform] and register the Android platform by specifying its package name and key hashes.
The Android SDK has the following features:
Here are what you need to use the Android SDK:
The Android SDK uses the following libraries that are automatically installed when installing the Android SDK:
You can install the Android SDK in your project. To do so,
You need to set Gradle by declaring a Maven repository to sync your project with the Android SDK. Depending on the version of Android Studio, how you declare repositories is different.
If you use Android Studio Arctic Fox, declare the Maven repository in dependencyResolutionManagement
in the project-level settings.gradle file. For more information, refer to Centralizing repositories declaration.
//If you use Android Studio Arctic Fox, add this block in settings.gradle.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
}
}
If you use an earlier version of Android Studio Arctic Fox, declare the Maven repository in allprojects
in the project-level build.gradle file.
// NOTE: You cannot declare repositories through 'allprojects' in Android Studio Arctic Fox.
allprojects {
repositories {
google()
jcenter()
maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/'}
}
}
To use the Kakao APIs, add the desired modules to the module-level build.gradle file according to the APIs you want to use.
dependencies {
implementation "com.kakao.sdk:v2-all:2.13.0" // Add all modules (Available in 2.11.0 or higher)
implementation "com.kakao.sdk:v2-user:2.13.0" // Kakao Login
implementation "com.kakao.sdk:v2-talk:2.13.0" // Kakao Talk Social, Kakao Talk messaging
implementation "com.kakao.sdk:v2-friend:2.13.0" // Friend picker
implementation "com.kakao.sdk:v2-story:2.13.0" // Kakao Story
implementation "com.kakao.sdk:v2-share:2.13.0" // Kakao Talk sharing
implementation "com.kakao.sdk:v2-navi:2.13.0" // Kakao Navi
}
dependencies {
implementation "com.kakao.sdk:v2-all-rx:2.13.0" // Add all modules (Available in 2.11.0 or higher)
implementation "com.kakao.sdk:v2-user-rx:2.13.0" // Kakao Login
implementation "com.kakao.sdk:v2-talk-rx:2.13.0" // Kakao Talk Social, Kakao Talk messaging
implementation "com.kakao.sdk:v2-friend-rx:2.13.0" // Friend picker
implementation "com.kakao.sdk:v2-story-rx:2.13.0" // Kakao Story
implementation "com.kakao.sdk:v2-share-rx:2.13.0" // Kakao Talk sharing
implementation "com.kakao.sdk:v2-navi:2.13.0" // Kakao Navi
}
Some modules in the Kakao SDK are dependent on another module. If you add the Common or Auth module, its subordinate modules are automatically added together.
To communicate with the Kakao Sever through the Kakao APIs, allow the internet permission.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sample">
<!-- Allow Internet permission -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
...
To use the Java 8 features, the following code snippet must be included in your project. If not, add the following to the module-level build.gradle file. For more details, refer to the official site for Android app developers.
// Use Java 8 features
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// For Kotlin projects
kotlinOptions {
jvmTarget = "1.8"
}
}
If you enable shrinking, obfuscation, and optimization when buiding the release version of your app, add the following -keep lines in the ProGuard rules file to exclude the Kakao SDK from shrinking and obfuscation.
-keep class com.kakao.sdk.**.model.* { <fields>; }
-keep class * extends com.google.gson.TypeAdapter
# https://github.com/square/okhttp/pull/6792
-dontwarn org.bouncycastle.jsse.**
-dontwarn org.conscrypt.*
-dontwarn org.openjsse.**
After installing the SDK, you need to initialize the SDK for initial setup.
Initialize the KakaoSDK
instance by adding the init
method in the Application
instance with your Native app key.
class GlobalApplication : Application() {
override fun onCreate() {
super.onCreate()
// Other codes for initialization
// Initialize Android SDK
KakaoSdk.init(this, "${YOUR_NATIVE_APP_KEY}")
}
}
Key hashes are the values hashed from the certificate fingerprints of the certificate and used to check if your app is malicious and the updates or changes are from your original app. When you call the Kakao APIs, the API server checks if the key hash added to your request matches the value specified in [My Application] > [Platform] for identification. Key hash has two types:
Use one of methods to get a debug key hash and a release key hash.
Using Terminal to generate Debug and Release key hashesTo get key hashes using Terminal, you need the Keytool program, key and certificate management tool. On Windows, you need to download OpenSSL for Windows libraries. on Mac, Keytool has already installed.
Run the command in Command Prompt according to your operating system.
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android | openssl sha1 -binary | openssl base64
keytool -exportcert -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore -storepass android -keypass android | openssl sha1 -binary | openssl base64
keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | PATH_TO_OPENSSL_LIBRARY\bin\openssl base64
You can also get a key hash by calling the getKeyHash()
method provided in Utility
through the Android SDK. With this, you can obtain either a debug or release key hash depending on when you call this method.
import com.kakao.sdk.common.util.Utility
var keyHash = Utility.getKeyHash(this)
If you use Google Play App Signing, you must use the SHA-1 certificate fingerprint obtained on the Google Play Console, not generating a Release key hash on the Terminal. Refer to Play Console Help > Use Play App Signing for more details.
keytool -printcert -file ./deployment_cert.der
echo "{SHA-1_CERTIFICATE_FINGERPRINT}" | xxd -r -p | openssl base64
When you get key hashes, go to [My Application] > [Platform] > [Android platform registration], and register all of your key hashes in 'Key hash'. Refer to Register platforms for more details.
Make sure to add all debug key hashes by development environments and a release key hash. You cannot make Kakao API calls from an app which a key hash is not registered in.
If several developers are participated in developing an app, you must register all debug key hashes that each developer has because they have all different debug key hashes depending on development environments.
You can migrate the Legacy Android SDK (version 1.x.x) to the latest version of Android SDK (version 2.x.x) using this migration guide.
The latest Android SDK has a simpler module structure compared to the Legacy Android SDK. The latest Android SDK provides the common
module that contains the common and utility features and the Kakao Login function. In addition, each module provides APIs that are grouped by service under Client
, and object and structure information is located in Model
, which allows you to use the Android SDK more efficiently and conveniently.
The token-based APIs refer to the APIs that require Kakao Login with which you can get an access token. To use the token-based APIs in the latest Android SDK, you must implement Kakao Login that the common
module provides. When you add the desired modules, the common
module is installed by default.
KakaoSDK
.Utility
in the com.kakao.util
package.KakaoSDK
.Utility
.Name | Legacy SDK | SDK |
---|---|---|
Initializing Kakao SDK | init() | init() |
Getting a key hash | getKeyHash() | getKeyHash() |
LoginActivity
.AuthService
.Session
.UserManagement
.LoginActivity
.UserApiClient
in the v2-user
module, except for the Checking token presence API.AuthApiClient
.Name | Legacy SDK | SDK |
---|---|---|
Checking if Kakao Talk is installed | - | isKakaoTalkLoginAvailable() |
Login with Kakao Talk | - | loginWithKakaoTalk(context) |
Login with Kakao Account | - | loginWithKakaoAccount(context) |
Checking token presence | isOpened() | hasToken() |
Logout | requestLogout() | logout() |
Unlink | requestUnlink() | unlink() |
Retrieving token information | requestAccessTokenInfo() | accessTokenInfo() |
Retrieving user information | me() | me() |
Retrieving shipping address | shippingAddresses() | shippingAddresses() |
Storing user information | requestUpdateProfile(properties) | updateProfile() |
Requesting additional consent | updateScopes(scopes) | loginWithNewScopes(context, scopes) |
Retrieving user agreed terms | serviceTerms() | serviceTerms() |
Getting consent to desired term | - | loginWithKakaoTalk(context, serviceTerms) loginWithKakaoAccount(context, serviceTerms) |
KOSessionTask
.TalkApiClient
in the v2-talk
module.Name | Legacy SDK | SDK |
---|---|---|
Retrieving Kakao Talk profile | requestProfile() | profile() |
Retrieving list of friends | requestAppFriends() | friends() |
KakaoLinkService
.ShareClient
in the v2-share
module.context
for the Sending message API. In Android SDK 2.11.0, the names of the module, classes, and methods related to Kakao Talk sharing have been changed due to the change of its service name. To see more detailed changes, see Version history.
Name | Legacy SDK | SDK |
---|---|---|
Checking if Kakao Talk is installed | - | isKakaoTalkSharingAvailable() |
Sending with default template | sendDefault(template) | shareDefault(context, defaultFeed) |
Sending with custom template | sendCustomWithTemplateId(templateId) | shareCustom(context, templateId) |
Sending a scrap message | sendScrapWithURL(url) | shareScrap(context, url) |
Uploading an image | uploadImage(imageFile) | uploadImage(file) |
Scraping an image | scrapWithImageURL:imageURL: | scrapImage(url) |
KakaoTalkService
.TalkApiClient
in the v2-talk
module.Name | Legacy SDK | SDK |
---|---|---|
Sending me with default template | requestSendMemo(template) | sendDefaultMemo(template) |
Sending me with custom template | requestSendMemo() | sendCustomMemo(templateId) |
Sending me a scrap message | requestSendMemo(url) | sendScrapMemo(url) |
Sending friends with default template | sendMessageToFriends(template, uuids) | sendDefaultMessage(template, receiverUuids) |
Sending friends with custom template | sendMessageToFriends(templateId, uuids) | sendCustomMessage(templateId, receiverUuids) |
Sending friends a scrap message | sendMessageToFriend(url, uuids) | sendScrapMessage(url, receiverUuids) |
KakaoStoryService
.StoryApiClient
in the v2-story
module.Name | Legacy SDK | SDK |
---|---|---|
Validating Kakao Story user | requestIsStoryUser() | isStoryUser() |
Retrieving Kakao Talk profile | requestProfile() | profile() |
Posting text story | requestPostNote(content) | postNote(content) |
Posting photo story | requestPostPhoto(content, fileList) | postPhoto(content, images) |
Posting link story | requestPostLink(content, linkUrl) | postLink(content, linkInfo) |
Retrieving specified story | requestGetMyStory(id) | story(id) |
Retrieving multiple stories | requestGetMyStories() | stories() |
Deleting story | requestDeleteMyStory(id) | delete(id) |
Uploading image | - | upload(images) |
Scraping web page | - | linkInfo(url) |
PlusFriendService
.KakaoTalkService
.TalkApiClient
in the v2-talk
module.Name | Legacy SDK | SDK |
---|---|---|
Adding Kakao Talk Channel | addFriend(plusFriendId) | addChannelUrl(channelPublicId) |
Starting Kakao Talk Channel chat | chat(plusFriendId) | channelChatUrl(channelPublicId) |
Checking Kakao Talk Channel relationship | requestPlusFriends() | channels() |
KakaoNaviService
.newBuilder()
of each class and setNaviOptions()
to set parameters.NaviClient
in the v2-navi
module.Name | Legacy SDK | SDK |
---|---|---|
Navigation | navigate(destination) | navigateIntent(location, naviOption) |
Getting URL for navigation | - | Deprecated navigateWebUrl(location, naviOption) |
Sharing location | shareDestination(destination) | shareDestinationIntent(location, naviOption) |
Setting conditions for navigation | newBuilder() setNaviOptions(options) |
NaviOption() |
Setting conditions for destination information | newBuilder() setNaviOptions(options) |
Location() |
Name | Legacy SDK | SDK |
---|---|---|
Registering push token | registerPushToken(pushToken, deviceId) | - |
Retrieving push token | getPushTokens() | - |
Deleting push token | deregisterPushToken(deviceId) | - |
To see how to use the Legacy Kakao SDK for Android, see Getting Started Guide for Legacy Android SDK.
It is highly recommended to migrate to the new version of Android SDK as soon as possible because the Legacy version may not be supported anymore.