> For the complete documentation index, see [llms.txt](https://tyson.gitbook.io/vigamedoc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tyson.gitbook.io/vigamedoc/en/ke-hu-duan-jie-ru/android-jie-ru.md).

# 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

```groovy
    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:

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

```groovy
    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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tyson.gitbook.io/vigamedoc/en/ke-hu-duan-jie-ru/android-jie-ru.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
