Step1. インストール

    Step1. インストール


    記事の要約

    必ずShopLiveHandlerを登録してください。

    ShopLive.setHandlerインターフェースを使用すると、ボタンの機能を実装できます。以下の ハンドラー登録 ガイドを参照してください。


    app/build.gradle に依存関係を追加します。分割ライブラリをご利用ください。統合ライブラリは 1.7.4 以降サポート終了です。


    統合ライブラリ (1.7.4 以降サポート終了)

    dependencies {
        def shoplive_sdk_version = "1.5.11"
        
        // Shoplive combined packaging
        implementation "cloud.shoplive:shoplive-sdk-all:$shoplive_sdk_version" // live + short-form
    }


    分割ライブラリ

    // 1) リポジトリを追加 — Shoplive SDK は mavenCentral での配布を終了しました。
    //    settings.gradle の dependencyResolutionManagement.repositories、
    //    またはプロジェクトの build.gradle の repositories に宣言してください。
    maven {
        url = uri("https://sdk.shoplive.cloud/maven-repo")
    }
    
    // 2) 依存関係を追加 — app/build.gradle
    dependencies {
        def shoplive_sdk_version = "1.8.14"
        def your_exoplayer_version = "2.19.1"
        def your_media3_version = "1.10.1"
        def shoplive_exoplayer_version = your_exoplayer_version + "." + "20"
        def shoplive_media3_version = your_media3_version + "." + "3"
    
        // POM に推移的依存関係が含まれないため、必要なアーティファクトを個別に宣言してください。
        implementation "cloud.shoplive:shoplive-common:$shoplive_sdk_version" // must required
        implementation "cloud.shoplive:shoplive-network:$shoplive_sdk_version" // must required
    
        // プレイヤーのバックエンドは exoplayer / media3 のどちらか一方のみを宣言してください。
        // 両方を宣言しないでください。
        implementation "cloud.shoplive:shoplive-exoplayer:$shoplive_exoplayer_version"
        // Exoplayer は近日 deprecated になります。
        // https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide
        // implementation "cloud.shoplive:shoplive-media3:$shoplive_media3_version"
    
        implementation "cloud.shoplive:shoplive-sdk-core:$shoplive_sdk_version" // for live player
    
        implementation "cloud.shoplive:shoplive-short-form:$shoplive_sdk_version" // for short-form player
    
        implementation "cloud.shoplive:shoplive-filter:$shoplive_sdk_version" // for short-form editor
        implementation "cloud.shoplive:shoplive-video-editor:$shoplive_sdk_version" // for short-form editor
    
        implementation "cloud.shoplive:shoplive-permission:$shoplive_sdk_version" // for permission request
    }
    


    ハンドラーを登録する

    Shoplive Android SDKから複数のイベントを受け取るために Handler を登録します

    ShopLive.setHandler(object : ShopLiveHandler() {
        override fun handleNavigation(context: Context, url: String) {
            // Do something
        }
    })

    Proguard ルールの追加

    R8 ビルドを行うと難読化の問題が発生する可能性があります。以下の内容を追加してください。

    -keep public class cloud.shoplive.** { *; }
    -dontwarn cloud.shoplive.**
    -keep class org.json.** { *; }
    -keep class com.google.gson.** { *; }