硅谷社交1--环信集成

2019-11-26 15:01 来源:未知
dependencies {
    compile project(':redpacketlibrary')
    compile project(':EaseUI')
    compile fileTree(dir: 'libs', include: '*.jar', exclude: 'android-support-multidex.jar')
    //考虑到在eclipse中,直接使用源码
//    compile ('com.anthonycr.grant:permissions:1.0'){
//        exclude module: 'support-v4'
//    }
// 从v7包中移除v4
    compile ('com.android.support:appcompat-v7:23.4.0'){
        exclude module: 'support-v4'
    }
}
// 配置权限
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />


<!-- 设置环信应用的appkey -->
<meta-data
    android:name="EASEMOB_APPKEY"
    android:value="atguigudemo#demo" />
<!-- 声明sdk所需的service -->
<service android:name="com.hyphenate.chat.EMChatService"
    android:exported="true"
    />
<!-- 声明sdk所需的receiver -->
<receiver android:name="com.hyphenate.chat.EMMonitorReceiver">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_REMOVED"/>
        <data android:scheme="package"/>
    </intent-filter>
    <!-- 可选filter -->
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.USER_PRESENT" />
    </intent-filter>
</receiver>
编译后报如下错误
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:Program FilesJavajdk1.7.0_45binjava.exe'' finished with non-zero exit value 2

错误原因:EaseUI中的v4包和主项目中的v7包冲突,
解决办法:在项目的build.gradle将v7包中的v4包移除

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile ('com.android.support:appcompat-v7:23.4.0'){
        exclude module: 'support-v4'
    }
    compile project(':easeui')
}

(4)下载SDK

#Fri May 20 14:56:58 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-2.8-all.zip

32450新蒲京网站 ,3.集成EaseUI
(1卡塔 尔(英语:State of Qatar)将EaseUI模块导入到项目中,并涉及到主项目中
(2卡塔尔配置AndroidManifest.xml项目清单文件

2)环信的Demo演示
(1卡塔 尔(阿拉伯语:قطر‎检查demo的gradle版本和android studio的gradle版本是还是不是雷同
  1.项目的build.gradle

  2.项目的gradle文件夹

(3卡塔 尔(英语:State of Qatar)阅读集成文书档案
      ①环信平台架构
      ②环信后台数据管理
      ③环信中数据的传递

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

1.环信SDK介绍

  

(5卡塔尔国错误清除

  

参照小说:

public class IMApplication extends Application {
    private static Context mContext;
    @Override
    public void onCreate() {
        super.onCreate();
        EMOptions options = new EMOptions();
        options.setAutoAcceptGroupInvitation(false);// 不自动接受群邀请信息
        options.setAcceptInvitationAlways(false);// 不总是一直接受所有邀请

        // 初始化EaseUI
        EaseUI.getInstance().init(this,options);

        // 初始化模型层数据
        Modle.getInstance().init(this);

        mContext = this;
    }

    // 获取全局上下文
    public static Context getApplication(){
        return mContext;
    }
}

// 在AndroidManifest.xml中关联
<application
    android:name=".IMApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
</application>

(3卡塔尔国在环信官英特网创办应用
(4)创建IMApplication,初始化EaseUI

(1卡塔尔国登录环信官方网站
           http://www.easemob.com/

(2卡塔 尔(阿拉伯语:قطر‎如若改造后,依然编译不通过,能够在build.gradle中期维改进

(2卡塔尔注册账号

TAG标签:
版权声明:本文由32450新蒲京网站发布于葡萄游戏厅_棋牌游戏,转载请注明出处:硅谷社交1--环信集成