Di seguito è l'eccezione che ottengo anche se la mia chiave API per l'applicazione server e browser è valida. L'ho controllato usando l'arricciatura. Invio la richiesta GCM in entrambi i formati UTF-8 e JSON. Provarlo da una rete aziendale esterna.Codice di risposta HTTP 401 in Google GCM
java.io.IOException: Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/send
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1345)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1339)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:993)
at java.net.URLConnection.getContent(URLConnection.java:688)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContent(HttpsURLConnectionImpl.java:406)
at gcm1.MessageUtil.sendMessage(MessageUtil.java:58)
Posso conoscere il motivo e la soluzione per questo?
Per gli utenti che stanno navigando in questo momento, se all'improvviso si è verificato questo errore senza apportare modifiche specifiche (la chiave del server) uguali, è probabilmente necessario importare il progetto in Firebase. Vedi la mia risposta [qui] (http://stackoverflow.com/a/37801206/4625829). –