0

我正在尝试通过 parse.com 开设一个新帐户:

https://www.parse.com/docs/android_guide

但是,当我到达线路时:

user.setUsername("a");

然后它向我显示一个弹出窗口:“应用程序必须停止......”然后它退出

这是日志猫:

02-28 18:35:42.849: E/AndroidRuntime(1862): FATAL EXCEPTION: main
02-28 18:35:42.849: E/AndroidRuntime(1862): java.lang.ExceptionInInitializerError
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseUser.stripAnonymity(ParseUser.java:327)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseUser.put(ParseUser.java:319)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseUser.setUsername(ParseUser.java:274)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.example.salebook.RegisterActivity$1.onClick(RegisterActivity.java:34)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at android.view.View.performClick(View.java:4204)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at android.view.View$PerformClick.run(View.java:17355)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at android.os.Handler.handleCallback(Handler.java:725)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at android.os.Looper.loop(Looper.java:137)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at android.app.ActivityThread.main(ActivityThread.java:5041)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at java.lang.reflect.Method.invokeNative(Native Method)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at java.lang.reflect.Method.invoke(Method.java:511)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at dalvik.system.NativeStart.main(Native Method)
02-28 18:35:42.849: E/AndroidRuntime(1862): Caused by: java.lang.RuntimeException: You must call Parse.initialize(context, oauthKey, oauthSecret) before using the Parse library.
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseUser.checkApplicationContext(ParseUser.java:858)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseUser.getCurrentUser(ParseUser.java:731)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseUser.registerAuthenticationProvider(ParseUser.java:929)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseAnonymousUtils.initialize(ParseAnonymousUtils.java:42)
02-28 18:35:42.849: E/AndroidRuntime(1862):     at com.parse.ParseAnonymousUtils.<clinit>(ParseAnonymousUtils.java:36)
02-28 18:35:42.849: E/AndroidRuntime(1862):     ... 15 more

这是我的代码(我必须说服务器中不存在“a”用户名)

regbutton.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                ParseUser user = new ParseUser();
                user.setUsername("a");
                user.setPassword("a");
                user.setEmail("email@example.com");
                try {
                    user.signUp();
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        });

谢谢

4

1 回答 1

1

在使用 Parse 库之前,您必须调用 Parse.initialize(context, oauthKey, oauthSecret)。

于 2013-02-28T18:46:56.207 回答