错误:(29,44)错误:无法访问AbstractSafeParcelable 找不到com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable的类文件
public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
private static final String TAG = MyFirebaseInstanceIDService.class.getSimpleName();
@Override
public void onTokenRefresh() {
super.onTokenRefresh();
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
// Saving reg id to shared preferences
storeRegIdInPref(refreshedToken);
// sending reg id to your server
sendRegistrationToServer(refreshedToken);
// Notify UI that registration has completed, so the progress indicator can be hidden.
Intent registrationComplete = new Intent(Config.REGISTRATION_COMPLETE);
registrationComplete.putExtra("token", refreshedToken);
LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}
private void sendRegistrationToServer(final String token) {
// sending gcm token to server
Log.e(TAG, "sendRegistrationToServer: " + token);
}
private void storeRegIdInPref(String token) {
SharedPreferences pref = getApplicationContext().getSharedPreferences(Config.SHARED_PREF, 0);
SharedPreferences.Editor editor = pref.edit();
editor.putString("regId", token);
editor.commit();
}
}
答案 0 :(得分:11)
在您的Gradle文件中,所有版本的google-play-service和firebase都应使用相同版本。
正在使用:
compile 'com.google.firebase:firebase-core:10.0.1'
您应该使用:
compile 'com.google.firebase:firebase-messaging:10.0.1'
//而不是9.4.0
因此,如果您使用的是google-play-services,请将版本更新为10.0.1 。