Skip to content

Initializing Stormpath sdk after already initializing once causes fatal crash #29

@LithiumSheep

Description

@LithiumSheep

This is generally only an issue with incremental builds with AS instant run. There is the helper method Stormpath.isInitialized() but a better solution may be to initialize Stormpath in the project's Application subclass.

Here is the stracktrace when Stormpath is initialized after already being initialized:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.lithium.authproject, PID: 28651 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lithium.authproject/com.lithium.authproject.MainActivity}: java.lang.IllegalStateException: You may only initialize Stormpath once! at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519) at android.app.ActivityThread.-wrap19(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: java.lang.IllegalStateException: You may only initialize Stormpath once! at com.stormpath.sdk.Stormpath.init(Stormpath.java:48) at com.stormpath.sdk.Stormpath.init(Stormpath.java:33) at com.lithium.authproject.MainActivity$override.initStormpath(MainActivity.java:47) at com.lithium.authproject.MainActivity$override.onCreate(MainActivity.java:35) at com.lithium.authproject.MainActivity$override.access$dispatch(MainActivity.java) at com.lithium.authproject.MainActivity.onCreate(MainActivity.java:0) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)  at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4519)  at android.app.ActivityThread.-wrap19(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6119)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions