我嘗試在我的Gradle項目中更新GCM服務(Google雲消息)庫(從7.5到8.3.0)。 但現在,使用這個新版本,我無法啓動之前完美工作的以前的活動。GCM更新7.5至8.3.0致命異常
其處理以下錯誤的代碼:
Intent in = new Intent(this, MyGcmListenerService.class);
startService(in);
MyGcmListenerService.java:
public class MyGcmListenerService extends GcmListenerService
{
private static final String TAG = "MyGcmListenerService";
@Override
public void onMessageReceived(String from, Bundle data)
{
Log.w(TAG, "onMessageReceived");
}
返回的錯誤:
FATAL EXCEPTION: AsyncTask #1
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
E/AndroidRuntime: at com.google.android.gms.gcm.GcmListenerService.zzo(Unknown Source)
E/AndroidRuntime: at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
E/AndroidRuntime: at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
搖籃文件:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}
如果我回滾到以前的GCM版本(7.5),它會按預期回退。 你知道什麼改變了嗎?我檢查了更新日誌,但我無法找到任何有關它的信息。 https://developers.google.com/android/guides/releases
謝謝您的幫助
我假設你做了一個乾淨的重建? –