Android

Demo工程git克隆地址:

git clone http://dnsdk.vimedia.cn:8080/r/VigameDemo-Android.git

第一步:添加maven仓库地址

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "http://dnsdk.vimedia.cn:8081/repository/vimedia-public/"
        }

    }
}
  allprojects {
    repositories {
        maven {
           //动能maven仓库
            url "http://dnsdk.vimedia.cn:8081/repository/vimedia-public/"
        }
        //ironsource maven仓库
        maven {url  "https://dl.bintray.com/ironsource-mobile/android-adapters/"}
        maven {url "https://dl.bintray.com/ironsource-mobile/android-sdk"}
    }
  }

根目录下gradle.properties文件中添加:

android.enableJetifier=true
android.useAndroidX=true

第二步:引入仓库中的模块

    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'androidx.navigation:navigation-fragment:2.3.0'
    implementation 'androidx.navigation:navigation-ui:2.3.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.18'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.vimedia.core:common:1.2.1'
    implementation 'com.vimedia.core:kinetic:1.5.9'
    implementation 'com.vimedia.core:plugin:1.1.1'
    implementation 'com.vimedia.ad:manager:1.4.5'
    implementation 'com.vimedia.ad:ironsource_JuHe:1.0.2'
    implementation 'com.vimedia.tj:manager:1.0.5'
    implementation 'com.vimedia.track:manager:1.0.7'
    implementation 'com.vimedia.pay:manager:1.0.8'
    implementation 'com.vimedia.game:manager:1.3.6'

第三步:在 build.gradle 中加入Unity桥接模块

    implementation 'com.vimedia.game:unity:1.2.1'

第四步:添加动能的混淆过滤文件

buildTypes {

        release {
            minifyEnabled true
            shrinkResources false
            // 此处添加 'vigame_proguard.pro' 过滤sdk的混淆
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'vigame_proguard.pro'  
            signingConfig signingConfigs.release
            zipAlignEnabled true
        }
    }

如果release版本不开启混淆,可跳过

第五步:添加框架代码调用

1.修改应用的Application类。

在MyApplication类对应生命周期中加入模块的调用代码:

public class MyApplication extends Application {
    /**
     * onCreate lifecycle.
     */
    @Override
    public void onCreate() {
        super.onCreate();
        DNSDK.applicationOnCreate(this);
    }

    /**
     * onLowMemory lifecycle.
     */
    @Override
    public void onLowMemory() {
        super.onLowMemory();
    }

    /**
     * attachBaseContext lifecycle.
     */
    @Override
    protected void attachBaseContext(final Context base) {
        super.attachBaseContext(base);
        DNSDK.applicationAttachBaseContext(this, base);
    }

}

或者

直接将MyApplication类继承DNApplication:

public class MyApplication extends DNApplication {

}

2.修改主Activity

将主Acitivity继承UniWbActivity即可。

第六步:修改Manifest文件

添加相关的参数配置,并将VigameStartActivity设置为启动的Activit,application标签的android:name 设置为com.libVigame.VigameApplication 或 xxx.xx.x.MyApplication

    <meta-data
    android:name="com.vigame.sdk.appid"
    android:value="${DN_APPID}" />
    <meta-data
    android:name="com.vigame.sdk.appkey"
    android:value="${DN_APPKEY}" />
    <meta-data
    android:name="com.vigame.sdk.prjid"
    android:value="${DN_PRJID}" />
    <meta-data
    android:name="com.vigame.sdk.channel"
    android:value="${DN_CHANNEL}" />

    <activity
          android:name="com.vimedia.game.VigameStartActivity"
          android:configChanges="orientation|keyboardHidden|screenSize"
          android:label="@string/app_name"
          android:theme="@style/AppWelcome"
          android:screenOrientation="portrait">
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />

              <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
    </activity>

第七步:放入配置文件并修改

拷贝VigameConfig.xml和agrement.html到assets目录

通过assets文件夹中的ConfigVigame.xml进行配置,注意必须属性一定要设置,属性说明如下:

第八步:配置测试相关项

1.修改app/build.gradle文件,修改包名、渠道名、umeng参数

建议使用如下示例的包名,以方便广告展示

    defaultConfig {
        manifestPlaceholders = [
            DN_CHANNEL      : "google",
            DN_APPID        : "37683",
            DN_APPKEY       : "wfm542g5dc40n0qmynbtxhthj2kdnhcm7gc99fs1ts8jloayyz",
            DN_PRJID        : "3361",
            UMENG_APPKEY    : "591e8a3275ca3549e8000e5c",
            GDTAppId        : "",
            GDTAppKey       : "",
            KuaiShou_Appname: "",
            HEADLINE_APPID  : "",
            KuaiShou_Appname: "",
            HEADLINE_APPID  : "",
            KuaiShou_Appid  : "",
            ReYunAppKey     : "",
            ADMOB_APP_ID: "ca-app-pub-7851203648968517~5682113463"
        ]
    }

2.修改开屏广告的背景

开屏广告默认内置一张白色背景,如需修改改背景文件,请将要替换的背景图放在res/drawable/目录并重命名为bg_splash_vigame.png。

最后更新于