OkHttp's NullPointerException in HttpUrl.class

简介: 1 java.lang.RuntimeException:Unable to resume activity {com.xxxx.center/com.xxxx.
1 java.lang.RuntimeException:Unable to resume activity {com.xxxx.center/com.xxxx.center.activity.LoadActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
2 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3284)
3 ......
4 java.lang.NullPointerException:Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
5 okhttp3.HttpUrl.canonicalize(HttpUrl.java:1612)
6 okhttp3.FormBody$Builder.add(FormBody.java:110)
7 com.xxx.http.okhttp.request.PostFormRequest.addParams(PostFormRequest.java:125)
8 com.xxx.http.okhttp.request.PostFormRequest.buildRequestBody(PostFormRequest.java:40)
9 com.xxx.http.okhttp.request.OkHttpRequest.generateRequest(OkHttpRequest.java:70)
10 com.xxx.http.okhttp.request.RequestCall.generateRequest(RequestCall.java:79)
11 com.xxx.http.okhttp.request.RequestCall.buildCall(RequestCall.java:55)
12 com.xxx.http.okhttp.request.RequestCall.execute(RequestCall.java:84)
13 com.xxx.center.utils.HttpUtils.post(HttpUtils.java:45)
14 com.xxx.center.manager.AppBuessinesManager.serverInit(AppBuessinesManager.java:74)
15 com.xxx.center.activity.LoadActivity.onResume(LoadActivity.java:302)
16 android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1267)
17 android.app.Activity.performResume(Activity.java:6567)
18 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3269)
19 android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3315)
20 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2651)
21 android.app.ActivityThread.access$800(ActivityThread.java:182)
22 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
23 android.os.Handler.dispatchMessage(Handler.java:111)
24 android.os.Looper.loop(Looper.java:194)
25 android.app.ActivityThread.main(ActivityThread.java:5766)
26 java.lang.reflect.Method.invoke(Native Method)
27 java.lang.reflect.Method.invoke(Method.java:372)
28 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1059)
29 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:825)

今天测试在小米5.0-6.0的机型中测试发现一个空指针的异常,经过排查后发现OkHttp的请求参数不能为null,这个请求接口会上传当前机型的手机号、ip地址和其他的一些物理参数,当没有获取成功时就返回null,所以对于参数进行判空,否则就赋值为 parameter = “”;

相关文章
|
11月前
|
Java Spring
【Java用法】Spring之@Nullable和@NotNull注释的使用
【Java用法】Spring之@Nullable和@NotNull注释的使用
201 0
Mockito框架抛出NullPointerException
一文详细讲解Mockito框架是怎么抛出NullPointerException的整个过程和解决方式。
5880 0
|
4月前
|
搜索推荐 Java 开发者
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException 问题处理
【5月更文挑战第14天】org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException 问题处理
140 1
|
4月前
|
Java Spring
java.lang.Exception: Method a() should be public
java.lang.Exception: Method a() should be public
48 0
|
4月前
|
Java Maven Spring
SpringBoot运行出现 Lookup method resolution failed; nested exception is java.lang.IllegalStateException
SpringBoot运行出现 Lookup method resolution failed; nested exception is java.lang.IllegalStateException
984 0
|
Java API
SpringBoot报错:java.lang.IllegalStateException: getReader() has already been called for this request
SpringBoot报错:java.lang.IllegalStateException: getReader() has already been called for this request
467 0
|
Java 开发者
Java:Optional处理NullPointerException空指针异常的利器
Java:Optional处理NullPointerException空指针异常的利器
145 0
|
Java 数据库 Spring
Failed to instantiate [java.lang.Long]: No default constructor found;nested exception is java.lang()
Failed to instantiate [java.lang.Long]: No default constructor found;nested exception is java.lang()
Failed to instantiate [java.lang.Long]: No default constructor found;nested exception is java.lang()
|
SQL Java 关系型数据库
记录:springboot使用resultType空指针java.lang.NullPointerException: null...【亲测有效】
记录:springboot使用resultType空指针java.lang.NullPointerException: null...【亲测有效】
412 0
PowerMock - java.lang.RuntimeException: test should never throw an exception to this level
PowerMock - java.lang.RuntimeException: test should never throw an exception to this level
727 0
PowerMock - java.lang.RuntimeException: test should never throw an exception to this level