java.lang.NullPointerException: SugarContext has not been initialized properly. Call SugarContext.init(Context) in your Application.onCreate() method and SugarContext.terminate() in your Application.onTerminate() method.

Stack Overflow | MontiRabbit | 6 months ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 1

    Robolectric Unit Testing Sugar ORM

    Stack Overflow | 6 months ago | MontiRabbit
    java.lang.NullPointerException: SugarContext has not been initialized properly. Call SugarContext.init(Context) in your Application.onCreate() method and SugarContext.terminate() in your Application.onTerminate() method.

    Root Cause Analysis

    1. java.lang.NullPointerException

      SugarContext has not been initialized properly. Call SugarContext.init(Context) in your Application.onCreate() method and SugarContext.terminate() in your Application.onTerminate() method.

      at com.orm.SugarContext.getSugarContext()
    2. com.orm
      TestSugarApp.insertUserTest
      1. com.orm.SugarContext.getSugarContext(SugarContext.java:24)
      2. com.orm.SugarRecord.save(SugarRecord.java:360)
      3. com.orm.TestSugarApp.insertUserTest(TestSugarApp.java:53)
      3 frames
    3. Java RT
      NativeMethodAccessorImpl.invoke0
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      1 frame