Android SDK 介绍及导入

1、环境要求

  • 建议使用Android Studio 2.3及以上版本
  • Java编译版本JDK1.7以上
  • Android SDK最低支持API 21即安卓5.0以上版本

2、导入SDK

将LongChatSDK.jar 的jar包放到项目中的lib文件夹下面,然后右击Jar文件,点击Add As Library

3、配置工程

3.1权限配置

<uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <!--//网络权限,当禁用后,无法进行检索等相关业务-->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <!--//读取设备硬件信息,统计数据-->
    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
    <!--//读取系统信息,包含系统版本等信息,用作统计-->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!--//获取设备的网络状态,鉴权所需网络代理-->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!--//允许sd卡写权限,需写入地图数据,禁用后无法显示地图-->
    <uses-permission
        android:name="android.permission.WRITE_SETTINGS"
        tools:ignore="ProtectedPermissions" />
    <!--//获取统计数据-->
    <uses-permission android:name="android.permission.GET_TASKS" />
    <!--//鉴权所需该权限获取进程列表-->
    <uses-permission android:name="android.permission.CAMERA" />
    <!--//使用步行AR导航,配置Camera权限-->

    <!-- 这个权限用于进行网络定位-->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <!-- 这个权限用于访问GPS定位-->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位-->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!-- 获取运营商信息,用于支持提供运营商信息相关的接口-->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位-->
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <!-- SD卡读取权限,用户写入离线定位数据-->
    <uses-permission
        android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
        tools:ignore="ProtectedPermissions" />

3.2 SDK配置

<service android:name="com.longchat.base.service.QDIMService" />

        <receiver android:name="com.longchat.base.receiver.QDNetworkChangeReceiver"/>

3.3 混淆配置

-keep class com.longchat.base.dao.**{*;}
-keep class com.longchat.base.model.**{*;}
-keep class com.longchat.base.database.**{*;}
-keep class com.longchat.base.http.model.**{*;}
-keep class com.longchat.base.command.**{*;}
-keep class com.longchat.base.notify.**{*;}
#保证数据库表类不被混淆
-keep class longchat.base.databases.** { *; }
########okhttp#########
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

-dontwarn okio.**

# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain service method parameters.
-keepclassmembernames,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
########okhttp#########
-keepattributes *Annotation*
-keepclassmembers class * {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }

# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}
### greenDAO 3
-keep class org.greenrobot.greendao.**{*;}
-keep public class * extends org.greenrobot.greendao.AbstractDao
-keepclassmembers class * extends org.greenrobot.greendao.AbstractDao {
public static java.lang.String TABLENAME;
}
-keep class **$Properties

-keepclassmembers class **$Properties {*;}

# If you do not use SQLCipher:
-dontwarn org.greenrobot.greendao.database.**
# If you do not use Rx:
-dontwarn rx.**

3.4 SDK所需的依赖

compile 'net.zetetic:android-database-sqlcipher:3.5.9@aar'
    implementation 'org.greenrobot:greendao:3.2.2'

    compile 'com.google.code.gson:gson:2.8.4'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    compile 'com.squareup.okio:okio:1.14.0'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
    compile "io.reactivex.rxjava2:rxjava:2.1.14-RC1"
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'

    compile 'org.greenrobot:eventbus:3.1.1'

4、SDK初始化

QDClient.getInstance().init(getApplicationContext());

5、类图