通用Android SDK API
最近更新:2021-12-15

通用Android SDK API

SDK 集成

添加SDK到工程中

  • 解压缩 JVaasContent-android-X.X.X-release.zip 集成压缩包。
  • 复制libs/* 到工程 libs/ 目录下。

在App.gradle中加入maven仓库地址

allprojects { repositories { google() jcenter() } }
          allprojects {
    repositories {
        google()
        jcenter()
    }
}

        
此代码块在浮窗中显示

在使用的module中加入依赖,具体sdk版本根据发布的文档为准

//在gradle的Android节点下添加,如下 android { ... ... defaultConfig { applicationId "你的包名" ... ... multiDexEnabled true ndk { abiFilters 'armeabi-v7a' } manifestPlaceholders = [ // 设置manifest.xml中的变量 JPUSH_PKGNAME: applicationId, JPUSH_APPKEY : "你的 Appkey ", //Portal上注册的包名对应的 appKey. JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可. ] } repositories { flatDir { dirs "libs", "libs" } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 } } dependencies { ...... implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.squareup.okhttp3:okhttp:3.11.0' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:support-v4:28.0.0' //支持ijkplayer进行播放,非必选,建议添加,否则有可能无法检测到全部的播放状态 implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8' implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8' //implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8' //implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8' //implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8' //implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8' implementation(name:'JVaasContent-android-${SDK_VERSION}', ext:'aar')//修改为具体的sdk版本 }
          
//在gradle的Android节点下添加,如下
android {
    ...
    ...
    defaultConfig {
        applicationId "你的包名"
        ...
        ...

        multiDexEnabled true
        ndk {
            abiFilters 'armeabi-v7a'
        }
        manifestPlaceholders = [
                // 设置manifest.xml中的变量
                JPUSH_PKGNAME: applicationId,
                JPUSH_APPKEY :  "你的 Appkey ", //Portal上注册的包名对应的 appKey.
                JPUSH_CHANNEL:  "developer-default", //暂时填写默认值即可.
        ]
    }
    repositories {
        flatDir {
            dirs "libs", "libs"
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}
dependencies {
        ......
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.squareup.okhttp3:okhttp:3.11.0'
        implementation 'com.google.code.gson:gson:2.8.5'
        implementation 'com.android.support:recyclerview-v7:28.0.0'
        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:support-v4:28.0.0'

        //支持ijkplayer进行播放,非必选,建议添加,否则有可能无法检测到全部的播放状态
        implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
        implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
        //implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
        //implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
        //implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
        //implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'

        implementation(name:'JVaasContent-android-${SDK_VERSION}', ext:'aar')//修改为具体的sdk版本

}

        
此代码块在浮窗中显示

AndroidManifest.xml

                  
        <!-- Required -->
        <meta-data
            android:name="JPUSH_APPKEY"
            android:value="${JPUSH_APPKEY}" /> <!-- </>值来自开发者平台取得的AppKey -->
        <meta-data
            android:name="JPUSH_CHANNEL"
            android:value="${JPUSH_CHANNEL}" />

        
此代码块在浮窗中显示

混淆

若您的App开启了混淆,请为我们的SDK添加下述混淆规则

-keep class cn.jiguang.**{ *; } -dontwarn javax.annotation.** -dontwarn sun.misc.Unsafe -dontwarn org.conscrypt.* -dontwarn okio.** -dontwarn tv.danmaku.** ###其他混淆 -keep class android.support.v4.**{ public *; } -keep class android.support.v7.**{ public *; } -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); }
          -keep class cn.jiguang.**{
    *;
}
-dontwarn javax.annotation.**
-dontwarn sun.misc.Unsafe
-dontwarn org.conscrypt.*
-dontwarn okio.**
-dontwarn tv.danmaku.**

###其他混淆
-keep class android.support.v4.**{
    public *;
}
-keep class android.support.v7.**{
    public *;
}

-keepclassmembers class * extends android.app.Activity { public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

        
此代码块在浮窗中显示

如果您的应用启用了资源混淆或资源缩减,您需要保留SDK的资源,SDK的资源名都是以ksad_开头的。您可以在资源混淆配置⽂文件添加如下配置:

          <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@layout/ksad_*,@id/ksad_*,@style/ksad_*,
@drawable/ksad_*,@string/ksad_*,@color/ksad_*,@attr/ksad_*,@dimen/ksad_*"
/>

        
此代码块在浮窗中显示

冲突解决

1、图片加载库异常,编译不通过

More than one file was found with OS independent path 'lib/armeabi-v7a/libRSSupport.so'

android { packagingOptions { exclude 'lib/*/libRSSupport.so' exclude 'lib/*/librsjni.so' } }
          android {
    packagingOptions {
      
        exclude 'lib/*/libRSSupport.so'

        exclude 'lib/*/librsjni.so'
    }
}

        
此代码块在浮窗中显示

2、当小视频fragment有嵌套时可能会有界面切换时视频在后台播放的情况,解决方法:在fragment的onHiddenChanged中调用LittleVideoFragment的onHiddenChangedfragment ```

文档内容是否对您有帮助?

Copyright 2011-2022, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 深圳市和讯华谷信息技术有限公司

在文档中心打开