我希望通过GCM获取令牌ID
我的代码:
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken("xxxx", GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Log.i("error", "GCM Registration Token: " + token);
错误日志:
04-29 18:20:52.275: E/AndroidRuntime(7382): FATAL EXCEPTION: IntentService[RegIntentService]
04-29 18:20:52.275: E/AndroidRuntime(7382): java.lang.NoSuchMethodError: android.support.v4.content.ContextCompat.getNoBackupFilesDir
04-29 18:20:52.275: E/AndroidRuntime(7382): at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
04-29 18:20:52.275: E/AndroidRuntime(7382): at com.google.android.gms.iid.zzd.<init>(Unknown Source)
04-29 18:20:52.275: E/AndroidRuntime(7382): at com.google.android.gms.iid.zzd.<init>(Unknown Source)
04-29 18:20:52.275: E/AndroidRuntime(7382): at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
04-29 18:20:52.275: E/AndroidRuntime(7382): at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
04-29 18:20:52.275: E/AndroidRuntime(7382): at com.app.network.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:43)
04-29 18:20:52.275: E/AndroidRuntime(7382): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
04-29 18:20:52.275: E/AndroidRuntime(7382): at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 18:20:52.275: E/AndroidRuntime(7382): at android.os.Looper.loop(Looper.java:213)
04-29 18:20:52.275: E/AndroidRuntime(7382): at android.os.HandlerThread.run(HandlerThread.java:61)
如何解决它?