android 突然取不到RegistrationID

sdk
android
标签: #<Tag:0x00007fb8348cff48> #<Tag:0x00007fb8348cfe08>

(小树) #1

原本使用的是android sdk 205,以前运行正常,这几天发现调用JPushInterface.getRegistrationID取到的ID为空字符串,更换sdk为219,在eclipse里打开jpush调试模式,输出如图所示,是什么问题,有人知道吗!!!!谢谢!


#2

更换sdk的时候是否有严格按照升级文档进行。

获取不到registrationId说明集成失败,你需要检查下集成,看集成文档。

你的日志体现的似乎是连接服务器失败,这个是你网络的原因


(小树) #3

原本没换SDK的时候,是好的,后来发现取不到registerid,才升级了sdk,只是更换了版本,修改了makefile,手机的网也是通的,所以很奇怪!


#4

你是用什么方法取不到registrationId?

有没有获取registrationID不成功的日志?


(小树) #5
   JPushInterface.init(this);
    String registerid = JPushInterface.getRegistrationID(getApplicationContext());

是用这个方法调用的,取回来的id是空字符串
另外在下面的代码负责了接收


#6

先问一下,你的这个获取不到是一台手机不行还是都不行?

机型是什么?

再参考这里:


(小树) #7

是一个原来可以,现在不可以的手机,机型是三星 Note3 lite


#8

你参考一下这个贴,点我
你这个应该也是一样的,是首次注册获取registrationID的方法,之后要获取registrationID应该通过
public static String getRegistrationID(Context context)
来获取


(小树) #9

我是用这种方式获取的,我试了下,虚拟机是可以获取到的,但是实际的手机不可以,提示信息就是帖子开头的信息,手机型号为三星GALAXY Note 3 Lite,手机访问其它网址正常。


#10

这样,你将应用卸载重装,然后提供从init开始的所有日志

我们需要完整的日志来判断一下,直接贴文本即可


(小树) #11

代码是
JPushInterface.setDebugMode(true);
Util.printLog(tag, "极光 init ");
JPushInterface.init(this);
String registerid = JPushInterface.getRegistrationID(getApplicationContext());
Util.printLog(tag, "注册极光 ### registerid = " + registerid);
运行的日志结果是registerid是空字符串

09-14 17:08:12.267: D/JPush(11220): [JPushInterface] action:init - sdkVersion:2.1.9, buildId:326
09-14 17:08:50.867: D/JPush(11220): [JPushGlobal] metadata: appKey - c0e07e7cad10fe500cc2b54a
09-14 17:08:51.597: D/JPush(11220): [JPushGlobal] metadata: channel - developer-default
09-14 17:08:58.677: D/MainActivity(11220): 注册极光 ### registerid =

09-14 17:13:36.087: D/MainActivity(11220): start
09-14 17:13:36.087: D/MainActivity(11220): resume
09-14 17:13:36.097: I/Choreographer(11220): Skipped 20388 frames!  The application may be doing too much work on its main thread.
09-14 17:13:36.227: D/JPush(11220): [PushService] Action: init PushService
09-14 17:13:36.227: D/JPush(11220): [AndroidUtil] action:checkValidManifest
09-14 17:13:36.257: W/JPush(11220): [AndroidUtil] You should make main activity extends InstrumentedActivity (JPush), otherwise you will not see user click and user active time start on report in Portal. 
09-14 17:13:36.287: D/MainActivity(11220): onAccuracyChanged
09-14 17:13:36.297: D/JPush(11220): [PushService] onStartCommand - intent:Intent { act=cn.jpush.android.intent.REPORT cmp=com.lkpower.oaandroid/cn.jpush.android.service.PushService (has extras) }, pkg:com.lkpower.oaandroid, connection:0
09-14 17:13:36.297: D/JPush(11220): [PushService] Action - handleServiceAction - action:cn.jpush.android.intent.REPORT
09-14 17:13:36.307: D/JPush(11220): [PushService] onStartCommand - intent:Intent { act=cn.jpush.android.intent.INIT cmp=com.lkpower.oaandroid/cn.jpush.android.service.PushService (has extras) }, pkg:com.lkpower.oaandroid, connection:0
09-14 17:13:36.307: D/JPush(11220): [PushService] Action - handleServiceAction - action:cn.jpush.android.intent.INIT
09-14 17:13:36.307: D/JPush(11220): [PushService] Action - restartNetworkingClient, pid:11220
09-14 17:13:36.307: I/JPush(11220): [NetworkingClient] Begin to run in ConnectingThread - id:1246
09-14 17:13:36.367: D/JPush(11220): [ConnectingHelper] To get sis - host:s.jpush.cn, port:19000, selection:0
09-14 17:13:36.447: D/OAWebViewClient(11220): pagestarted file:///android_asset/www/html/cache.html
09-14 17:13:36.447: D/OAWebViewClient(11220): ### 创建任务 1
09-14 17:13:36.467: W/BindingManager(11220): Cannot call determinedVisibility() - never saw a connection for the pid: 11220
09-14 17:13:36.517: I/Timeline(11220): Timeline: Activity_idle id: android.os.BinderProxy@56fbdc5 time:881045
09-14 17:13:36.747: I/chromium(11220): [INFO:CONSOLE(104)] "Mozilla/5.0 (Linux; Android 5.0; SM-N9008S Build/LRX21V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.121 Mobile Safari/537.36 mobile", source: file:///android_asset/www/html/cache.html (104)
09-14 17:13:36.747: I/chromium(11220): [INFO:CONSOLE(105)] "5.0 (Linux; Android 5.0; SM-N9008S Build/LRX21V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/43.0.2357.121 Mobile Safari/537.36 mobile", source: file:///android_asset/www/html/cache.html (105)
09-14 17:13:36.797: I/chromium(11220): [INFO:CONSOLE(163)] "javascript in", source: file:///android_asset/www/html/cache.html (163)
09-14 17:13:36.807: D/OAWebViewClient(11220): pagefinished file:///android_asset/www/html/cache.html
09-14 17:13:36.867: D/OAWebViewClient(11220): null
09-14 17:13:36.867: D/OAWebViewClient(11220): ### 取消任务 onPageFinished 1
09-14 17:13:36.867: D/OAWebViewClient(11220): ### 当前URL file:///android_asset/www/html/cache.html
09-14 17:13:39.377: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:s.jpush.cn
09-14 17:13:39.377: W/JPush(11220): java.lang.Exception: Failed to resolve host dns - s.jpush.cn
09-14 17:13:39.377: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:13:39.377: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:13:39.377: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:13:39.377: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:13:39.377: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:13:39.377: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:13:39.387: D/JPush(11220): [ConnectingHelper] To get sis - host:sis.jpush.io, port:19000, selection:1
09-14 17:13:42.407: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:sis.jpush.io
09-14 17:13:42.407: W/JPush(11220): java.lang.Exception: Failed to resolve host dns - sis.jpush.io
09-14 17:13:42.407: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:13:42.407: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:13:42.407: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:13:42.407: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:13:42.407: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:13:42.407: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:13:42.427: D/JPush(11220): [ConnectingHelper] To get sis - host:easytomessage.com, port:19000, selection:2
09-14 17:13:45.437: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:easytomessage.com
09-14 17:13:45.437: W/JPush(11220): java.lang.Exception: Failed to resolve host dns - easytomessage.com
09-14 17:13:45.437: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:13:45.437: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:13:45.437: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:13:45.437: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:13:45.437: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:13:45.437: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:13:45.437: D/JPush(11220): [ConnectingHelper] To get sis - host:113.31.17.108, port:19000, selection:3
09-14 17:13:45.447: D/JPush(11220): [ConnectingHelper] SIS Receiving...
09-14 17:13:51.447: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:113.31.17.108
09-14 17:13:51.447: W/JPush(11220): java.net.SocketTimeoutException
09-14 17:13:51.447: W/JPush(11220): 	at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:598)
09-14 17:13:51.447: W/JPush(11220): 	at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
09-14 17:13:51.447: W/JPush(11220): 	at java.net.PlainDatagramSocketImpl.doRecv(PlainDatagramSocketImpl.java:163)
09-14 17:13:51.447: W/JPush(11220): 	at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:171)
09-14 17:13:51.447: W/JPush(11220): 	at java.net.DatagramSocket.receive(DatagramSocket.java:274)
09-14 17:13:51.447: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:13:51.447: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:13:51.447: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:13:51.447: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:13:51.447: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:13:51.447: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:13:51.447: W/JPush(11220): Caused by: android.system.ErrnoException: recvfrom failed: EAGAIN (Try again)
09-14 17:13:51.447: W/JPush(11220): 	at libcore.io.Posix.recvfromBytes(Native Method)
09-14 17:13:51.447: W/JPush(11220): 	at libcore.io.Posix.recvfrom(Posix.java:161)
09-14 17:13:51.447: W/JPush(11220): 	at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
09-14 17:13:51.447: W/JPush(11220): 	at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
09-14 17:13:51.447: W/JPush(11220): 	... 9 more
09-14 17:13:54.467: D/JPush(11220): [ConnectingHelper] Open connection with default - ip:113.31.17.106, port:7000
09-14 17:13:57.477: D/JPush(11220): [ConnectingHelper] Open connection failed - ret:-993
09-14 17:13:57.477: D/JPush(11220): [NetworkingClient] Action - closeConnection - connection:-1386745856
09-14 17:13:57.487: D/JPush(11220): [NetworkingClient] Return of Close jni connection - 0
09-14 17:13:57.487: D/JPush(11220): [PushService] Action - onDisconnected - connection:0
09-14 17:13:57.497: D/JPush(11220): [ConnectingHelper] Action - sendConnectionChanged
09-14 17:13:57.497: D/JPush(11220): [PushService] Action - retryConnect - disconnectedTimes:0
09-14 17:13:57.507: D/JPush(11220): [PushService] onDisconnected and retry restart conn - delay:3000
09-14 17:14:00.507: D/JPush(11220): [PushService] Action - restartNetworkingClient, pid:11220
09-14 17:14:00.517: I/JPush(11220): [NetworkingClient] Begin to run in ConnectingThread - id:1256
09-14 17:14:00.517: D/JPush(11220): [ConnectingHelper] To get sis - host:s.jpush.cn, port:19000, selection:0
09-14 17:14:03.527: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:s.jpush.cn
09-14 17:14:03.527: W/JPush(11220): java.lang.Exception: Failed to resolve host dns - s.jpush.cn
09-14 17:14:03.527: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:14:03.527: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:14:03.527: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:14:03.527: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:14:03.527: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:14:03.527: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:14:03.537: D/JPush(11220): [ConnectingHelper] To get sis - host:sis.jpush.io, port:19000, selection:1
09-14 17:14:06.537: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:sis.jpush.io
09-14 17:14:06.537: W/JPush(11220): java.lang.Exception: Failed to resolve host dns - sis.jpush.io
09-14 17:14:06.537: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:14:06.537: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:14:06.537: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:14:06.537: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:14:06.537: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:14:06.537: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:14:06.547: D/JPush(11220): [ConnectingHelper] To get sis - host:easytomessage.com, port:19000, selection:2
09-14 17:14:09.557: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:easytomessage.com
09-14 17:14:09.557: W/JPush(11220): java.lang.Exception: Failed to resolve host dns - easytomessage.com
09-14 17:14:09.557: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:14:09.557: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:14:09.557: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:14:09.557: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:14:09.557: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:14:09.557: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:14:09.557: D/JPush(11220): [ConnectingHelper] To get sis - host:113.31.17.108, port:19000, selection:3
09-14 17:14:09.567: D/JPush(11220): [ConnectingHelper] SIS Receiving...
09-14 17:14:15.577: W/JPush(11220): [ConnectingHelper] Get sis info error - sisHost:113.31.17.108
09-14 17:14:15.577: W/JPush(11220): java.net.SocketTimeoutException
09-14 17:14:15.577: W/JPush(11220): 	at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:598)
09-14 17:14:15.577: W/JPush(11220): 	at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
09-14 17:14:15.577: W/JPush(11220): 	at java.net.PlainDatagramSocketImpl.doRecv(PlainDatagramSocketImpl.java:163)
09-14 17:14:15.577: W/JPush(11220): 	at java.net.PlainDatagramSocketImpl.receive(PlainDatagramSocketImpl.java:171)
09-14 17:14:15.577: W/JPush(11220): 	at java.net.DatagramSocket.receive(DatagramSocket.java:274)
09-14 17:14:15.577: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.a(Unknown Source)
09-14 17:14:15.577: W/JPush(11220): 	at cn.jpush.android.helpers.ConnectingHelper.sendSis(Unknown Source)
09-14 17:14:15.577: W/JPush(11220): 	at cn.jpush.android.service.k.run(Unknown Source)
09-14 17:14:15.577: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
09-14 17:14:15.577: W/JPush(11220): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
09-14 17:14:15.577: W/JPush(11220): 	at java.lang.Thread.run(Thread.java:818)
09-14 17:14:15.577: W/JPush(11220): Caused by: android.system.ErrnoException: recvfrom failed: EAGAIN (Try again)
09-14 17:14:15.577: W/JPush(11220): 	at libcore.io.Posix.recvfromBytes(Native Method)
09-14 17:14:15.577: W/JPush(11220): 	at libcore.io.Posix.recvfrom(Posix.java:161)
09-14 17:14:15.577: W/JPush(11220): 	at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
09-14 17:14:15.577: W/JPush(11220): 	at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
09-14 17:14:15.577: W/JPush(11220): 	... 9 more
09-14 17:14:16.447: W/JPush(11220): [ConnectingHelper] Unknown host exception!

#13

两个问题:

  1. init动作还未完成,就去获取regid值
  2. 设备网络是有问题的,确认你设备网络情况

从日志来看,并未发现集成成功,regid必须集成成功才能获取到,第一次集成成功会触发regid广播的,regid的获取广播也只有在第一次注册成功才会触发,以后也不会触发了,以后获取regid才通过接口获取

再次参考:


华为和三星上 获取registrationID为空
(小树) #14

那请问下,如何判断android的sdk是否集成成功呢?同时我在其它地方也调用了
String registerid = JPushInterface.getRegistrationID(getApplicationContext());但是也是空的


#15

日志看出你集成没有成功啊,集成成功,日志就会出现login succeed

你集成没有成功,不管怎么获取registrationId都不行的,第一次向极光服务器注册都没成功呢,还没有给你返回这个registrationID。

getRegistrationID这个方法是在第一次成功后,你需要获取这个信息的时候使用的。


(咔咔木樨) #16

09-23 10:43:34.283 12411-12411/? D/JPush: [JPushInterface] action:init - sdkVersion:2.1.9, buildId:326
09-23 10:43:34.306 12411-12411/? D/JPush: [JPushGlobal] metadata: appKey - bd76a9c4255fef6f0687d801
09-23 10:43:34.307 12411-12411/? D/JPush: [JPushGlobal] metadata: channel - developer-default

我的也是获取不到getRegistrationID,机型:努比亚z9,其他两部华为、小米,正常,官方的Demo也是获取不到,提示"get registrationid fied…"


#17

关于努比亚: