Android

Clone URL of Demo:

http://dnsdk.vimedia.cn:8080/summary/VigameDemo-Android-Google.git

1:Add maven repositories

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'http://developer.huawei.com/repo/'}
        maven { url 'https://dl.bintray.com/umsdk/release' }
        maven {
            url 'https://android-sdk.is.com/'
        }
    }

    dependencies {
        classpath 'com.huawei.agconnect:agcp:1.1.1.300'
        classpath 'com.android.tools.build:gradle:3.4.3'
    }
}
    allprojects {
    repositories {
        maven { url 'https://repo1.maven.org/maven2/' }
        maven { url "http://dnsdk.vimedia.cn:8081/repository/vigame-public/" }
        maven { url "http://dnsdk.vimedia.cn:8081/repository/vimedia-public/" }
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
        maven { url "https://dl.bintray.com/ironsource-mobile/android-adapters/"}
        maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk"}
        maven { url 'http://developer.huawei.com/repo/'}
        maven { url 'https://dl.bintray.com/umsdk/release'}
        maven { url 'https://maven.fabric.io/public'}

        maven { url "https://dl.bintray.com/mintegral-official/Andorid_ad_SDK_for_china_support"}
        maven { url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_china"}
        maven { url 'https://android-sdk.is.com/'}
    }
    }

2:Add in project gradle.properties

    android.enableJetifier=true
    android.useAndroidX=true

3:Implementation modules

    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.6'   
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    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'

    //#Module_Begin
    implementation 'com.vimedia.tj:umeng:1.1.4'
    implementation 'com.vimedia.ad:ironsource_JuHe:1.0.2.20210707_1'
    implementation 'com.vimedia.core:kinetic:1.6.4'
    implementation 'com.vimedia.ad:manager:1.5.5.20210709_3'
    implementation 'com.vimedia.game:manager:1.4.2'
    implementation 'com.vimedia.pay:manager:1.0.8'
    implementation 'com.vimedia.social:manager:1.0.4'
    implementation 'com.vimedia.tj:manager:1.0.6'
    implementation 'com.vimedia.track:manager:1.0.8'
    implementation 'com.vimedia.track:persona:1.0.7'
    implementation 'com.vimedia.core:plugin:1.1.1'
    implementation 'com.vimedia.game:unity:1.2.1'
    implementation 'com.vimedia.ext:manager:1.0.3'
    implementation 'com.vimedia.extensions:protocol:1.0.0'
    implementation 'com.vimedia.core:common:1.2.1'
    //#Module_End

4:Add proguard config

buildTypes {

        release {
            minifyEnabled true
            shrinkResources false
            // here added 'vigame_proguard.pro'
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'vigame_proguard.pro'  
            signingConfig signingConfigs.release
            zipAlignEnabled true
        }
    }

If the release version does not enable minify, you can skip

5:Add code in the project

5.1 Modify Application.java

Add code in the corresponding life cycle in MyApplication class:

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);
    }

}

Or

Made your MyApplication class inherit DNApplication:

public class MyApplication extends DNApplication {

}

5.2 Modify the main Activity

Change the main Acitivity to UniWbActivity or its subclasses.

6. Modify AndroidManifest.xml

Add related parameter configuration, And use VigameStartActivity as launch item.

    <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>

    <activity android:name="com.vimedia.unitybridge.UniWbActivity"
        android:label="@string/app_name"
        android:hardwareAccelerated="true"
        >

      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />

    </activity>

7. Put in the configuration file and modify

Copy VigameConfig.xml and agrement.html to assets dictionary.

And You can configurate ConfigVigame.xml in assets. Property description is as follows:

Name

description

necessary

GameOpenActivity

the path of your main Activity

yes

ScreenOrientation

the orientation of screen

no

SupportAdPositions

the adPositionName of supports

no

WithSplashAD

Support splash ad

no

IsSDK

'true' always and don't modify

yes

CompanyIndex

the index of company,default 1

yes

8:Configuration items of test

1.Open app/build.gradle,modify package/channel/umeng appkey.

Recommendation the package name as follows for Advertising display

    defaultConfig {
        manifestPlaceholders = [
            Splash_Orientation:"portrait",
            DN_APPID:"37683",
            DN_APPKEY:"wfm542g5dc40n0qmynbtxhthj2kdnhcm7gc99fs1ts8jloayyz",
            DN_CHANNEL:"google",
            DN_PRJID:"37683016",
            AppsFlyer_DevKey:"X9NxxaMp4neHCFYreDxtd5",
            ADMOB_APP_ID:"ca-app-pub-7851203648968517~3923216450",
            //#track_BEGAIN
            //#track_END
            //#TJ_BEGAIN
            UMENG_APPKEY:"5c7c964061f564f63a0008a8",
            //#TJ_END
            //#Pay_BEGAIN
            //#Pay_END
        ]
    }

2. Modify the background of Splash AD.

If needs,add "bg_splash_vigame.png.png" file in res/drawable.

最后更新于

这有帮助吗?