清单标签应用:
<application
android:name=".util.StartApplication"
android:allowBackup="true"
android:icon="@drawable/ic_guard"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:replace="android:name">
我的应用程序扩展了一个糖应用程序
StartApplication extends CoreApplication{...} //it is in a main module
CoreApplication extends com.orm.SugarApp{...} //it is in a library module
在 oncreate 我得到一个空指针:
public void onCreate() {
super.onCreate();
有人已经修好了?
这是我的堆栈跟踪:
java.lang.RuntimeException: Unable to create application br.com.egsys.guardronda.util.StartApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4641)
at android.app.ActivityThread.access$1500(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at android.content.ContextWrapper.getPackageManager(ContextWrapper.java:91)
at com.orm.SugarConfig.getMetaDataString(SugarConfig.java:74)
at com.orm.SugarConfig.getDatabaseName(SugarConfig.java:19)
at com.orm.SugarDb.<init>(SugarDb.java:27)
at com.orm.Database.<init>(Database.java:12)
at com.orm.SugarApp.onCreate(SugarApp.java:11)
at com.br.mobilecore.nucleo.CoreApplication.onCreate(CoreApplication.java:56)
at br.com.egsys.guardronda.util.StartApplication.onCreate(StartApplication.java:71)