跳转至

将 SohaGame SDK 添加到项目

前提条件

  • 目标 API 版本在 34 或更高

下载和安装 SDK

步骤 1: 下载

SohaGame 会向您提供所有必要的信息,例如游戏 ID、包名、Facebook App ID、付款包列表、API 列表等,所有这些都可以在我们游戏运营商提供的文档中找到。如果您需要任何帮助,请联系我们的项目运营商或语言支持人员。

Download Soha SDK.

步骤 2: 导入 SDK 到项目中

  1. 将 SohaSDK.aar 文件复制到 libs 目录中
       implementation(name: "SohaSDK3300", ext: "aar")
    
  2. 在 build.gradle 项目文件中添加以下代码:
    allprojects {
        repositories {
            google()
            jcenter()
            maven { url "https://jitpack.io" }
            maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
            flatDir {
                dirs 'libs'
            }
        }
    }
    
  3. 在 build.gradle 项目级别文件中添加 Google 服务:
       repositories {
       google()
       jcenter()
       maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
       maven { url "https://jitpack.io" }
       }
       dependencies {
            classpath 'com.android.tools.build:gradle:7.2.2'
            classpath 'com.google.gms:google-services:4.3.3'
            classpath 'com.google.firebase:perf-plugin:1.4.1'
            classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
       // 注意:不要将应用程序依赖项放在此处;它们属于各个模块的 build.gradle 文件中
       }
       }
    
  4. 将以下代码添加到 build.gradle 应用级别文件中
    dependencies {
         implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
        testImplementation 'junit:junit:4.13.2'
        implementation 'com.google.android.material:material:1.12.0'
        // COPY TO BUILD FILE APK DEMO
        //life circle
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
        //retrofit
        implementation 'com.squareup.retrofit2:retrofit:2.9.0'
        implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
        implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.5'
        api 'com.squareup.retrofit2:converter-gson:2.9.0'
        //firebase
        implementation platform('com.google.firebase:firebase-bom:33.7.0')
        implementation 'com.google.firebase:firebase-analytics'
        implementation 'com.google.firebase:firebase-messaging'
        implementation 'com.google.firebase:firebase-dynamic-links'
        implementation 'com.google.firebase:firebase-config'
        implementation 'com.google.firebase:firebase-perf'
        implementation 'com.google.android.gms:play-services-auth:21.3.0'
        implementation 'com.google.android.gms:play-services-ads-identifier:18.2.0'
        implementation 'com.google.guava:guava:33.0.0-android'
        implementation 'com.google.android.gms:play-services-auth:21.3.0'
        implementation 'com.google.android.gms:play-services-ads-identifier:18.2.0'
        implementation 'com.google.guava:guava:33.0.0-android'
        implementation 'com.google.firebase:firebase-iid:21.1.0'
        //facebook
        implementation 'com.facebook.android:facebook-login:16.0.1'
        //tiktok
        implementation 'com.bytedance.ies.ugc.aweme:opensdk-oversea-external:0.2.1.0'
        //iap
        implementation 'com.android.billingclient:billing:7.1.1'
        //mqtt
        implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
        implementation 'com.github.hannesa2:paho.mqtt.android:4.2'
        //apps flyer
        implementation 'com.appsflyer:af-android-sdk:6.12.1'
    
        implementation "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
        //glide
        implementation 'com.github.bumptech.glide:glide:4.16.0'
        annotationProcessor 'com.github.bumptech.glide:compiler:4.15.1'
        //multidex
        implementation 'androidx.multidex:multidex:2.0.1'
        implementation 'com.android.installreferrer:installreferrer:2.2'
        api 'androidx.work:work-runtime:2.9.0'
        // ui lib
        implementation 'com.github.ybq:Android-SpinKit:1.4.0'
        api 'com.intuit.sdp:sdp-android:1.1.0'
    }
    
  5. 在 gradle.properties 文件中启用 AndroidX
    android.enableJetifier=true
    android.useAndroidX=true