我正在尝试使用pusher-java-client1.2.1库连接到android中的pusher,我的连接代码如下所示
if(Utils.isOnline(mcontext)) {
PusherOptions pOptions = new PusherOptions();
pOptions.setAuthorizer(new HttpAuthorizer(Constants.PUSHER_AUTH_SRC_URL + "/auth.php"));
pusher = new Pusher(Constants.PUSHER_KEY, pOptions);
pusher.connect();
channel = pusher.subscribe(Utils.getPref(mcontext, "channel_name", ""));
Utils.setPref(mcontext, "OtherUserId", "");
}else{
Utils.setCustomToast(mcontext,Constants.NO_INTERNET,false);
}
我的这个代码在android 5.0及以上版本中工作正常但在android 4.4应用程序崩溃时跟随logcat输出
java.lang.NoClassDefFoundError: com.pusher.client.util.Factory
at com.pusher.client.Pusher.<init>(Pusher.java:83)
at com.driversafe.chat.MessageStatusApiCalling.pusherConnect(MessageStatusApiCalling.java:62)
at com.driversafe.chat.ApplicationLifeCycleHandler.onActivityCreated(ApplicationLifeCycleHandler.java:27)
at android.app.Application.dispatchActivityCreated(Application.java:189)
at android.app.Activity.onCreate(Activity.java:903)
at android.support.v4.app.BaseFragmentActivityDonut.onCreate(BaseFragmentActivityDonut.java:39)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:298)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:84)
at com.driversafe.SplashActivity.onCreate(SplashActivity.java:57)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
任何机构都可以建议我解决这个问题
答案 0 :(得分:0)
问题出在依赖关系中我使用google-play-service google play服务而pusher-java-client是冲突我通过使用特定依赖关系来解决问题google-play-service-gcm