gpt4 book ai didi

java - 创建用户时解析崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:40:38 24 4
gpt4 key购买 nike

我正在使用 Parse 作为我的 Android 应用程序的后端。当我尝试创建用户对象时,我只有一些 Android 设备的崩溃报告。崩溃的错误是:

Caused by: java.lang.IllegalArgumentException: 
You must register this ParseObject subclass before instantiating it.
at com.parse.ParseObject.<init>(ParseObject.java:184)

提交崩溃报告的设备是:

HTC Desire 510 (htc_a11ul)  2   33.3% Android 4.4
Xperia E3 (D2203) 1 16.7% Android 4.4
Galaxy S4 (jflte) 1 16.7% Android 4.4
Galaxy S5 (klte) 1 16.7% Android 4.4

这非常奇怪,因为我目前已经在 Samsung Note 4、Galaxy S4、S5 和 Nexus 5 上测试了我的代码,没有任何问题。我不确定为什么 Parse 要求我无处不在地进行子类化,因为我没有尝试使用 Parse 提供的子类功能。同样,我已经在其他设备上测试了这段代码,没有任何问题。

有人可以告诉我如何解决这个问题吗?我在下面包含了创建用户的代码,但它崩溃了。

谢谢!

    Parse.initialize(this, "XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXX");
ParseUser user = new ParseUser();
user.setUsername(email);
user.setPassword(confirmPassword);
user.setEmail(email);
user.put("deviceID", deviceID);
user.put("name", fullName);

progress = new ProgressDialog(Register.this);
progress.setMessage("Creating Account... Please Wait");
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progress.setIndeterminate(true);
progress.setCanceledOnTouchOutside(false);
progress.setCancelable(false);
progress.show();


user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
Intent i = new Intent(Register.this, DeviceSettingsIntro.class);
startActivity(i);
progress.hide();
btnRegister.setEnabled(true);
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
progress.hide();
checkParseError(e);
btnRegister.setEnabled(true);
}
}
});

最佳答案

您是否尝试过使用 Application 类初始化 Parse,如 Parse 快速入门指南所述?可能 Parse 没有初始化成功

创建一个扩展应用程序的类,并为内容:

@Override
public void onCreate() {
super.onCreate();

Parse.enableLocalDatastore(this); //might not be needed
Parse.initialize(this, "xxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");
}

编辑 list 标签,添加:

    android:name="com.yourpackage.applicationclass"

//so it should look like (for example) :
<application
android:name="com.yourpackage.yourapplicationclass"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

//put activities here

</application>

这样,无论 Activity 是什么,Parse 都会在您的应用程序启动时进行初始化。

关于java - 创建用户时解析崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30877073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com