请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

关于运行起来报空指针的问题

图片描述

01/19 01:32:11: Launching 'app' on Nexus 4 API 22.
App restart successful without requiring a re-install.
$ adb shell am start -n "com.example.activitydemo/com.mooc.ppjoke.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 31653 on device 'Nexus_4_API_22 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/le.activitydem: Late-enabling -Xcheck:jni
W/le.activitydem: Unexpected CPU variant for X86 using defaults: x86
W/le.activitydem: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setUseSessionTickets(Z)V (light greylist, reflection)
    Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setHostname(Ljava/lang/String;)V (light greylist, reflection)
    Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->getAlpnSelectedProtocol()[B (light greylist, reflection)
    Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setAlpnProtocols([B)V (light greylist, reflection)
W/le.activitydem: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, reflection)
    Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, reflection)
    Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, reflection)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/le.activitydem: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)
    Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)
    Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)
    Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)
    Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)
W/le.activitydem: Accessing hidden method Landroid/view/View;->getAccessibilityDelegate()Landroid/view/View$AccessibilityDelegate; (light greylist, linking)
W/le.activitydem: Accessing hidden method Landroid/app/ActivityThread;->currentApplication()Landroid/app/Application; (light greylist, reflection)
W/le.activitydem: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)
W/le.activitydem: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)
D/OkHttp: --> GET http://123.56.232.18:8080/serverdemo/feeds/queryHotFeedsList http/1.1
    --> END GET
D/OkHttp: <-- 200  http://123.56.232.18:8080/serverdemo/feeds/queryHotFeedsList (131ms)
    Content-Type: application/json;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Tue, 18 Jan 2022 17:32:12 GMT
D/OkHttp: {"status":200,"message":"成功","data":{"data":[]}}
    <-- END HTTP (52-byte body)
E/AndroidRuntime: FATAL EXCEPTION: arch_disk_io_0
    Process: com.example.activitydemo, PID: 31653
    java.lang.NullPointerException: Attempt to invoke virtual method 'void androidx.paging.DataSource.addInvalidatedCallback(androidx.paging.DataSource$InvalidatedCallback)' on a null object reference
        at androidx.paging.LivePagedListBuilder$1.compute(LivePagedListBuilder.java:199)
        at androidx.paging.LivePagedListBuilder$1.compute(LivePagedListBuilder.java:171)
        at androidx.lifecycle.ComputableLiveData$2.run(ComputableLiveData.java:101)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
D/OpenGLRenderer: HWUI GL Pipeline
I/Process: Sending signal. PID: 31653 SIG: 9**

真的很绝望,从下午卡到现在了。反复看视频哪里错误都没找出来,报错的地方都找不到,打断点都不知道打在哪。求老师尽快回复,谢谢!

正在回答 回答被采纳积分+3

1回答

LovelyChubby 2022-01-19 09:45:43

androidx.paging.DataSource.addInvalidatedCallback
on NullPointException这写的很清楚啊,你看看你返回的datasource对象是不是空的

0 回复 有任何疑惑可以回复我~
  • 提问者 云遮秋燕 #1
    找到问题了,是我实现createDataSource抽象方法的时候返回了null。现在是跑起来了,但抓不到后台数据。
    
    D/OkHttp: <-- 200  http://123.56.232.18:8080/serverdemo/feeds/queryHotFeedsList (158ms)
    D/OkHttp: Content-Type: application/json;charset=UTF-8
    D/OkHttp: Transfer-Encoding: chunked
        Date: Wed, 19 Jan 2022 05:26:53 GMT
    D/OkHttp: {"status":200,"message":"成功","data":{"data":[]}}
        <-- END HTTP (52-byte body)
    D/OkHttp: --> GET http://123.56.232.18:8080/serverdemo/feeds/queryHotFeedsList?pageCount=10feedId=0userId= http/1.1
        --> END GET
    D/OkHttp: <-- 400  http://123.56.232.18:8080/serverdemo/feeds/queryHotFeedsList?pageCount=10feedId=0userId= (45ms)
        Content-Type: application/json;charset=UTF-8
        Transfer-Encoding: chunked
        Date: Wed, 19 Jan 2022 05:26:53 GMT
        Connection: close
    D/OkHttp: {"timestamp":1642570013198,"status":400,"error":"Bad Request","message":"Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: \"10feedId=0userId=\"","path":"/serverdemo/feeds/queryHotFeedsList"}
        <-- END HTTP (301-byte body)
    回复 有任何疑惑可以回复我~ 2022-01-19 13:25:00
  • 提问者 云遮秋燕 #2
    这个问题解决了,url的字符串处理问题。但还是没有数据,这个url我寻过去只有一条数据
    {"status":200,"message":"成功","data":{"data":[]}}
    请问这样是正常的吗?请老师解答。
    回复 有任何疑惑可以回复我~ 2022-01-19 13:59:14
  • 提问者 云遮秋燕 #3
    这个老哥跟我的问题是一样的,https://coding.imooc.com/learn/questiondetail/pylDvYyrD32XkBNm.html。
    回复 有任何疑惑可以回复我~ 2022-01-19 14:10:02
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信