페이지 이동경로
  • Docs>
  • Getting Started

Getting Started

Legacy Android

This document describes how to integrate the Legacy Kakao SDK for Android (Legacy Android SDK) into your app. You can leverage the Kakao APIs by using with the Kakao SDK(Software Development Kit) in the iOS, Android, and JavaScript development environment. You can skip this page if you have ever used the Kakao SDK before.

Before you begin

- Select 'API 16: Android 4.1 (Jelly Bean)' or higher when you create a new project.

- Go to [My Application] > [Platform] and register the Android platform by specifying its package name and key hashes. Refer to Register platforms to see how to register a platform.

- To configure your project, you need the Native app key issued when creating your app. Go to [My Application] > [App Keys] to get the Native app key.

Install SDK

The Kakao SDK is built based on Gradle and provides an optimized environment for Android Studio, an official Integrated Development Environment(IDE). Thus, this document guides how to use the Kakao SDK in Android Studio.

Step1. Add a Maven repository to build.gradle(Project: {app name})

You can import the Kakao SDK by adding Maven repository to the build.gradle (Project: {app name}) file of your project in Android Studio. With this configuration, you do not need to download the SDK file.

If the repository setting is not completed as below, Android Studio cannot find the Kakao SDK, which causes the "Failed to resolve: com.kakao.sdk:usermgmt:1.30.6" error.

allprojects {
  repositories {
    google()
    jcenter()
    maven { url 'https://devrepo.kakao.com/nexus/content/groups/public/' }
  }
}
Step 2. Add modules to build.gradle(Module: app)

To use Kakao Login, Kakao Talk sharing, Kakao Talk messaging, Kakao Story or Kakao Navi service, you need set dependencies. Add the desired modules to the build.gradle(Module: app) file.

dependencies {
    // Kakao Login
    implementation group: 'com.kakao.sdk', name: 'usermgmt', version: '1.30.6'

    // Kakao Talk messaging
    implementation group: 'com.kakao.sdk', name: 'kakaotalk', version: '1.30.6'

    // Kakao Story
    implementation group: 'com.kakao.sdk', name: 'kakaostory', version: '1.30.6'

    // Kakao Talk sharing
    implementation group: 'com.kakao.sdk', name: 'kakaolink', version: '1.30.6'

    // Kakao Navi
    implementation group: 'com.kakao.sdk', name: 'kakaonavi', version: '1.30.6'
}

With "Sync Now" clicked after the build configuration above, the Kakao SDK is completely imported in your project.

How can I use the Kakao SDK in Eclipse?

Kakao officially does not support the Eclipse development environment anymore. If you want to use the Kakao SDK in Eclipse, you need to use the SDK with Gradle or Maven.

Set an app key

  1. Copy your Native app key from [My Application] > [App Keys].
  2. Go to app > src > main > AndroidManifest.xml in Android Studio.
  3. Add <meta-data> with your Native app key specified in the value attribute inside .
  4. Add the following code to allow internet permission: <uses-permission android:name="android.permission.INTERNET"/>.
<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />  <!-- Add internet permission.-->

<application>

    ...

    <meta-data
        android:name="com.kakao.sdk.AppKey"
        android:value="${YOUR_NATIVE_APP_KEY}" /> <!-- Set Native app key.-->
</application>

Add key hashes

The Kakao checks if your app is malicious by using the key hash generated for your app. When you call the Kakao APIs, the Kakao SDK checks if the key hash which your app has matches with the value set in [App Keys] for identification. A key hash is a value hashed from signing key signature of app and has two types― a debug key hash and a release key hash.

IMPORTANT: When registering key hashes

Make sure to add all debug key hashes by development environments and a release key hash in [My Application] > [Platform] > [Android platform registration]. 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 should register all debug key hashes that each developer has because they have all different debug key hashes depending on development environments.

To get key hashes, you can use Keytool, a management tool of key hashes and certificates. For Windows, you need to download OpenSSL for Windows libraries.

Debug key hash

A debug key hash is used to develop an app. You must generate a debug key hash according to your development environment and register your app with the generated debug key hash.

To generate your debug key hash, run the command in Command Prompt according to your operating system.

macOS
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android | openssl sha1 -binary | openssl base64
Windows
keytool -exportcert -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore -storepass android -keypass android | openssl sha1 -binary | openssl base64

After generating a debug key hash, go to [My Application] > [Platform] > [Android platform registration], and register your debug key hash in the [Key hash].

Release key hash

A release key hash is used when you publish your app. If you create a release build APK to release your app, sign it as release key store with *_.jks_ file extension, not debug key store.

To generate your release key hash, run the command in Command Prompt according to your operating system.

macOS
keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
Windows
keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | PATH_TO_OPENSSL_LIBRARY\bin\openssl sha1 -binary | openssl base64

After generating a release key hash, go to [My Application] > [Platform] > [Android platform registration], and register your release key hash in the [Key hash].

Generate a key hash with Kakao SDK

You can also generate a key hash by using the getKeyHash() method provided by the com.kakao.util package through Kakao SDK for Android. With this, you can obtain either debug or release key hash depending on when you call this method.

String keyHash = com.kakao.util.helper.Utility.getKeyHash(this /* context */);

Initialize SDK

Initialization is the process of connecting between the Kakao SDK and your app. For initializing the Kakao SDK, use the KakaoAdapter that is an abstract class inherited from IApplicationConfig interface and passed as a parameter. You must implement IApplicationConfig.getApplicationConfig() and return Application Context to provide the app information to the Kakao SDK.

Besides IApplicationConfig, KakaoAdapter inherits ISessionConfig interface to get the information needed to create the login session and IPushConfig interface related to Push settings. You can override these interfaces if you need to use or modify.

IApplicationConfig

Name Return Description
getApplicationContext Context Application Context

KakaoAdapter

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        // Initialize SDK 
        KakaoSDK.init(new KakaoAdapter() {

            @Override
            public IApplicationConfig getApplicationConfig() {
                return new IApplicationConfig() {
                    @Override
                    public Context getApplicationContext() {
                        return MyApplication.this;
                    }
                };
            }
        });
    }
}