Ted*_*y13 9 java mobile android parse-platform
我正在使用Parse作为我的Android应用程序的后端.当我尝试创建User对象时,我只有一些Android设备的崩溃报告.崩溃的错误是:
Caused by: java.lang.IllegalArgumentException:
You must register this ParseObject subclass before instantiating it.
at com.parse.ParseObject.<init>(ParseObject.java:184)
Run Code Online (Sandbox Code Playgroud)
提交崩溃报告的设备是:
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
Run Code Online (Sandbox Code Playgroud)
这是非常奇怪的,因为我目前在三星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);
}
}
});
Run Code Online (Sandbox Code Playgroud)
您是否尝试过按照快速入门指南所述Parse使用类进行初始化?可能没有初始化成功ApplicationParseParse
创建一个扩展 Application 的类,并为其内容:
@Override
public void onCreate() {
super.onCreate();
Parse.enableLocalDatastore(this); //might not be needed
Parse.initialize(this, "xxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");
}
Run Code Online (Sandbox Code Playgroud)
编辑您的清单 <application> 标签,添加以下内容:
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>
Run Code Online (Sandbox Code Playgroud)
这样,无论 Activity 如何,当您的应用程序启动时,Parse 将始终被初始化。
| 归档时间: |
|
| 查看次数: |
580 次 |
| 最近记录: |