Skip to main content

Android

This article guides you through setting up LINE as an identity provider, enabling your Android game to access Player Network authentication services.

Prerequisites

1. Set up the LINE app on LINE Developers Console

1. Create a LINE app

Before configuring the app for required platforms, log in to LINE Developers Console and create a developer account. With the developer account, use LINE Developers Console and create a channel (communication path between LINE functions and your app).

Create a channel
  1. On the Console home, click Create New Provider and follow the on-screen instructions to create the provider.

    Image: Create a LINE Provider

  2. In the Channels tab on the provider page, click Create a LINE Login channel.

  3. On the new channel creation page, enter required information and click Create.

  4. In the Basic settings tab on the channel page, check the Channel ID and other required information for Player Network SDK configuration.

    Image: Add LINE app information

  5. Configure the channel for Android.

    In the LINE Login tab on the channel page, enable Mobile app and enter required information.

    Image: LINE Login settings

    To add a new channel package name and corresponding signature to support a multi-store channel package, add a new line to enter the information.

    Image: Multiple package name in LINE console

  6. Click Update to save the configuration.

2. Add user permissions

Immediately after creating a channel, the channel is set to Developing mode. Only channel admin and testers have access to LINE login functions.

Add a tester
  1. Log in to LINE Developers Console.

  2. Select the corresponding channel from the most recently visited channels on the homepage.

    Image: Select LINE channel

  3. On the channel page, click Roles.

  4. In the Roles tab, click Invite by email.

    Image: LINE permission configuration

  5. Add testers in the Invite new members section.
    Email: LINE account of the tester
    Role: Tester

    Image: Add LINE tester

  6. Click Send Invitations to send tester invitations.

  7. Wait for the testers to accept the email invitation.

  1. Create an account for Player Network Console.
  2. Create a new project for your game, or join an existing one.
  3. Download the SDK.
  4. Integrate the SDK.
  5. Add LINE as an authentication method for your project on Player Network Console.

Step 1: Configure the SDK for LINE login

caution

As LINE SDK is only compatible with minSdkVersion >= 19, problems may occur while running on devices with Android 4.2 or lower versions. It is required to set minSdkVersion >= 19 for games.

note

As the LINE channel introduces Java8 new features, it is mandatory to use Java8 for Gradle settings. Use the D8 compiler to compile dex.

For more information, see ANT package.

Java8 compatibility
  • Unity 4.x, Unity 5.x compatibility

    If the number of methods exceeds 65536, see the DexMerge article to find a solution.

  • Unity 2017-2019 compatibility

    1. Upgrade Android Gradle to version 3.2, and configure for Java8 support
    2. Upgrade Unity Gradle to version 4.6 or higher (As verified by INTL: The latest version for Unity 2017 is version 4.6, for others are higher than version 4.10)
    3. Upgrade buildToolsVersion to version 28.0.1 or higher
  1. Open the project's INTLConfig.ini:

    INTLConfig.ini
    [INTL environment]
    # WARNING: You should change this URL to the production environment when you release your game.
    INTL_URL = https://test.intlgame.com
    GAME_ID = {INTL_GAME_ID}
    SDK_KEY = {INTL_SDK_KEY}
    [INTL Log]
    LOG_LEVEL = 1
    LOG_CONSOLE_OUTPUT_ENABLE = 1
    LOG_FILE_OUTPUT_ENABLE = 1
    LOG_ENCRYPT_ENABLE = 0
    LOG_COMPRESS_ENABLE = 0

    [Android LifeCycle]
    LIFECYCLE = Line
    [LINE]
    LINE_CHANNEL_ID = {INTL_LINE_CHANNEL_ID}
    LINE_CHECK_SDK_VERSION_ENABLE = 1
    • Set the SDK backend environment to INTL_URL = https://test.intlgame.com.
    • Replace {INTL_GAME_ID} and {INTL_SDK_KEY} with the GAME_ID and SDK_KEY assigned by Player Network Console.
    • Set LOG_LEVEL = 1, LOG_CONSOLE_OUTPUT_ENABLE = 1, LOG_FILE_OUTPUT_ENABLE = 1, LOG_ENCRYPT_ENABLE = 0, and LOG_COMPRESS_ENABLE = 0 to output console logs and log files without encrypting or compressing the output.
    • Add Line to LIFECYCLE. For more information, see SDK Environment.
    • Replace {INTL_LINE_CHANNEL_ID} with the ChannelID registered on LINE Developers.
    • LINE_CHECK_SDK_VERSION_ENABLE is used to validate the Android version on the device.
      If the Android version on the device is Android 4.2 or lower, calling LINE APIs will return not supported. Set the switch (Default: Enable) to 0 to disable it. However, games need to evaluate the risk to disable the switch.
  2. Add the following code to your gradle file.

    mainTemplate.gradle
    android{
    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }
    }
  3. Enable D8 compilation option.

    INTLCoreAndroidPostProcess.cs
    public static void GenerateGradleProperties(string pathToBuiltProject) {
    // ...
    using(StreamWriter writer = new StreamWriter(gradlePropertiesFile, true)) {
    // ...
    writer.WriteLINE("android.enableD8.desugaring=true");
    }
    }

Step 2: Add LINE login

LINE does not require an app installation before login.

  • If users have installed the LINE app on an Android device, the app will open for login. Otherwise, a web page will open.
  • LINE login authorization requires access to both the OpenID and profile of a player. The former is used to obtain a player's LINE OpenID, while the latter is used to obtain the player's LINE access token, which can be configured through the Permissions field. If the Permissions field is empty, access to OpenID and profile is used by default for Player Network SDK when users log in to LINE.
  1. Add an observer to handle authentication callbacks.

    // Add callbacks
    public void AddAuthObserver()
    {
    INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
    }

    // Remove callbacks
    public void RemoveAuthObserver()
    {
    INTLAPI.RemoveAuthResultObserver(OnAuthResultEvent);
    }

    // Process the INTLAuthResult callback
    public void OnAuthResultEvent(INTLAuthResult ret)
    {
    Debug.Log($"MethodID: {ret.MethodId}");

    string methodTag = "";
    if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_LOGIN)
    {
    methodTag = "Login";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_BIND)
    {
    methodTag = "Bind";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_AUTOLOGIN)
    {
    methodTag = "AutoLogin";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_QUERY_USER_INFO)
    {
    methodTag = "QueryUserInfo";
    }
    else if (authRet.MethodId == (int)INTLMethodID.INTL_AUTH_GET_AUTH_RESULT)
    {
    methodTag = "GetAuthResult";
    }
    }
  2. Call the AutoLogin method.

    INTLAPI.AutoLogin();
  3. Call the Login method to ask for user input if auto-login fails.

    INTLAPI.Login(INTLChannel.LINE); 
  4. Sync client authentication state with the game's backend and wait for the final authentication result.

Step 3: Test the login function

Search for the keyword "AuthResult" in the Player Network SDK logs to verify if the correct channel name and OpenID are returned. If they are, it indicates a successful configuration and the login function has been added successfully.

Step 4: Release the game

To enable LINE Login to the players, set the channel to Published.

Image: Release game