Application crashes when the app comes to the foreground. When the application is killed and relaunched, it doesn't crash but when it is minimized and reopened, it crashes with the below exception
java.lang.NoClassDefFoundError: com.moengage.locationlibrary.LocationHandlerImpl at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:324) at java.lang.Class.forName(Class.java:285) at com.moengage.location.GeoManager.getHandler(GeoManager.java:33) at com.moengage.core.MoEDispatcher.syncInAppsAndGeo(MoEDispatcher.java:209) at com.moengage.core.MoEDispatcher.onStart(MoEDispatcher.java:159) at com.moe.pushlibrary.MoEHelper.onNewIntent(MoEHelper.java:287) at com.moe.pushlibrary.MoEHelper.onStartInternal(MoEHelper.java:324) at com.moe.pushlibrary.MoEActivityLifeCycleCallBacks.onActivityStarted(MoEActivityLifeCycleCallBacks.java:33) at android.app.Application.dispatchActivityStarted(Application.java:205) at android.app.Activity.onStart(Activity.java:1146) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:542) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237) at android.app.Activity.performStart(Activity.java:6253) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 10-23 13:26:14.136 7406-7406/? I/Process: Sending signal. PID: 7406 SIG: 9
I did try the solution for NoClassDefFoundError but it didn't work. I am confused about it running when relaunched but not when it comes to foreground from minimized status.
Following is my applicaiton Class:
public class AppController extends Application implements PushManager.OnTokenReceivedListener {
MoEHelper helper;
@Override
public void onCreate() {
super.onCreate();
helper = MoEHelper.getInstance(getApplicationContext());
helper.autoIntegrate(this);
PushManager.getInstance().setTokenObserver(this);
Log.e("TAG", "onCreate() AppController");
SharedPreferences pref = getApplicationContext().getSharedPreferences("MoTest", Context.MODE_PRIVATE);
if (pref.contains("newInstall")) {
helper.setExistingUser(true);
} else {
helper.setExistingUser(false);
}
}
@Override
public void onTokenReceived(String token) {
Log.e("TAG", "Appcontroller Token: " + token);
}
}
and this is my MainActivity:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Check your LocationHandlerImpl.java file and see if GoogleApiClient and LocationServices are resolved. There is a possibility that you haven't added the dependency for the Location services.
If they are not resolved, add respective dependency to your Gradle file
'com.google.android.gms:play-services-location:XXX'
Sync and try running it again. That should do the job