NullPointerException addToRequestQueue(com.android.volley.Request,java.lang.String)'在null对象引用上 [英] NullPointerException addToRequestQueue(com.android.volley.Request, java.lang.String)' on a null object reference

查看:103
本文介绍了NullPointerException addToRequestQueue(com.android.volley.Request,java.lang.String)'在null对象引用上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AndroidHive注册登录,并且在此登录注册的示例项目中运行正常.

I'm using AndroidHive register login and it's working fine in example project of this login-register.

但是在尝试使用CardView和其他小部件进行多次尝试之后,此错误出现在LogCat上:

But after many attempts trying it with CardViews and other widgets, this error appears on the LogCat:

java.lang.NullPointerException: Attempt to invoke virtual method 'void client.myproject.app.AppController.addToRequestQueue(com.android.volley.Request, java.lang.String)' on a null object reference
            at client.myproject.RegisterActivity.registerUser(RegisterActivity.java:185)
            at client.myproject.RegisterActivity.access$300(RegisterActivity.java:35)
            at client.myproject.RegisterActivity$1.onClick(RegisterActivity.java:81)
            at android.view.View.performClick(View.java:4780)
            at android.view.View$PerformClick.run(View.java:19866)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            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:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

虽然这些代码可以在单个应用程序中正常运行(仅通过注册登录即可).

While these codes works fine in a single app (just with register login).

我正在使用Volley库.

I'm using Volley library.

推荐答案

在您的AndroidManifest.xml中添加

<application android:name="YOURPACKAGENAME.AppController" 
             android:allowbackup="true" 
             android:icon="@drawable/ic_launcher" 
             android:label="@string/app_name"
             android:theme="@style/AppTheme">

这篇关于NullPointerException addToRequestQueue(com.android.volley.Request,java.lang.String)'在null对象引用上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆