我知道有很多人在堆栈溢出时在这里发布此错误,但是在所有帮助下,我无法解决我的问题。
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laiq.laiq/com.laiq.laiq.UI.MainActivity}: java.lang.IllegalStateException: `Parse#enableLocalDatastore(Context)` must be invoked before `Parse#initialize(Context)`
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:156)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:211)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5373)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: Caused by: java.lang.IllegalStateException: `Parse#enableLocalDatastore(Context)` must be invoked before `Parse#initialize(Context)`
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.parse.Parse.enableLocalDatastore(Parse.java:68)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.laiq.laiq.UI.MainActivity.onCreate(MainActivity.java:37)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5990)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2332)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:156)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:211)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5373)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)
我创建了ParseApplication类,但是:
ParseCrashReport.enable(this)-无法解析
即使评论崩溃报告,问题似乎仍然存在
ParseApplication.class
public class ParseApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
ParseCrashReporting.enable(this);
Parse.enableLocalDatastore(this);
Parse.initialize(this, "xxx", "xxx"); --> my keys ofc
}
}
有人遇到这个问题吗?
该应用程序一开始就崩溃。
最佳答案
您的崩溃报告显示您正在第37行的MainActivity中调用Parse.enableLocalDatastore(Context)
:
Caused by: java.lang.IllegalStateException: `Parse#enableLocalDatastore(Context)` must be invoked before `Parse#initialize(Context)`
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.parse.Parse.enableLocalDatastore(Parse.java:68)
10-23 00:22:15.858 19723-19723/? E/AndroidRuntime: at com.laiq.laiq.UI.MainActivity.onCreate(MainActivity.java:37)
所有解析初始化都必须在扩展名
Application
中进行,也就是说,在您的情况下,扩展名是ParseApplication
。假设
ParseApplication
已正确添加到清单中,您要做的就是删除Parse.*
的onCreate()
中的MainActivity
代码。