I am trying to connect to pusher in android using pusher-java-client1.2.1 library and my code for connection is given below
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);
}
and my this code is working fine in android 5.0 and above versions but in android 4.4 application crashes with following logcat output
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)
can any body suggest me the solution of this problem
The Problem was in dependencies i have used google-play-service google play service and pusher-java-client are confliction sor i resolved issue by using specific dependencies google-play-service-gcm