Support Topics Documentation Slack YouTube Blog

ExceptionInInitializerError when init Android application

Hi,
Suddenly when I want to install the app in my device, I’m getting the error of ExceptionInInitializerError. This is the same device that I’ve always used to test the app, and I don’t understand why now is getting me this error.
Some help will be appreciated!
PD: Notice that in my code APPLICATION_ID AND SECRET_KEY have the correct values.
CODE:
public class BackendlessApplication extends Application {
public static final String APPLICATION_ID = “xxxx”;
public static final String SECRET_KEY = “xx”;
public static final String VERSION = “v1”;
public static final String SERVER_URL = “https://api.backendless.com”;
@Override
public void onCreate() {
super.onCreate();
Backendless.initApp(this, APPLICATION_ID, SECRET_KEY, VERSION); //This is line 20
}
}
ERROR:
10-07 17:06:08.815 20806-20806/com.exagon.touristbeach E/dalvikvm: Could not find class ‘com.backendless.io.BackendlessUserWriter’, referenced from method com.backendless.Backendless.initApp
10-07 17:06:08.819 20806-20806/com.exagon.touristbeach E/dalvikvm: Could not find class ‘weborb.v3types.core.DataServices’, referenced from method weborb.config.ORBConfig.init
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: FATAL EXCEPTION: main
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: java.lang.ExceptionInInitializerError
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.backendless.Backendless.<clinit>(Backendless.java:44)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.exagon.touristbeach.core.BackendlessApplication.onCreate(BackendlessApplication.java:20)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4566)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:156)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.os.Looper.loop(Looper.java:153)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5297)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: Caused by: java.lang.NullPointerException
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at weborb.types.Types.addClientClassMapping(Types.java:129)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.backendless.UserService.<init>(UserService.java:56)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.backendless.UserService.<clinit>(UserService.java:47)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.backendless.Backendless.<clinit>(Backendless.java:44)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.exagon.touristbeach.core.BackendlessApplication.onCreate(BackendlessApplication.java:20)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1000)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4566)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:156)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1400)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.os.Looper.loop(Looper.java:153)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5297)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-07 17:06:08.829 20806-20806/com.exagon.touristbeach E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)

I’ve just found the solution:

  1. Add multiDexEnabled = true in your default Config
  2. Add compile com.android.support:multidex:1.0.0 in your dependencies
  3. Application class extend MultiDexApplication instead of just Application

i tried to add multi dexing but still getting this error In Release Mode only

java.lang.ExceptionInInitializerError
at c.b.i0.c(Unknown Source:0)
at c.b.f.(Unknown Source:15)
at c.b.f.b(Unknown Source:0)
at com.example.tantamall.application.App.onCreate(Unknown Source:5)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1189)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'j.l.f

Have you tried a solution described here?