老程序集成的是极光IM的SDK后来让替换成环信的IM,今天把JMessage的SDK替换成成JPush的SDK。
本来想用在gradle中直接添加依赖,但用的是mavenCentral就没去更改。
登录极光,下载3.0.3版本的JPush和1.1.1版本的JCoreSDK进行替换,由于项目中原本用的2.x版本的JMessage的SDK,因此删除掉。并且项目中只使用了armeabi的.so文件,所以只复制出来一个进行替换。
然后报错,查看了一下,是自定义的Receiver中
JPushInterface.EXTRA_NOTIFICATION_ID //提示报错
替换成官方文档里的
// 打印所有的 intent extra 数据 private static String printBundle(Bundle bundle) { StringBuilder sb = new StringBuilder(); for (String key : bundle.keySet()) { if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) { sb.append("\nkey:" + key + ", value:" + bundle.getInt(key)); } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) { sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key)); } else if (key.equals(JPushInterface.EXTRA_EXTRA)) { if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) { ToolUtils.log(TAG, "This message has no Extra data"); continue; } try { JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA)); Iterator<String> it = json.keys(); while (it.hasNext()) { String myKey = it.next().toString(); sb.append("\nkey:" + key + ", value: [" + myKey + " - " + json.optString(myKey) + "]"); } } catch (JSONException e) { ToolUtils.log(TAG, "Get message extra JSON error!"); } } else { sb.append("\nkey:" + key + ", value:" + bundle.getString(key)); } } return sb.toString(); }然后删除AndroidManifest中极光IM的注册信息,其余配置不变。
解决更新。