2016-06-30 7 views
0

私は、Android Studioを使用してAndroidアプリでGoogleの通知を使用しようとした、よく私は、登録サービスのAndroid StudioのGCM

public class GCMRegistrationIntentService extends IntentService 
{ 

public static final String REGISTRATION_SUCCESS = "RegistrationSuccess"; 
public static final String REGISTRATION_ERROR = "RegistrationError"; 

public GCMRegistrationIntentService() { 
    super(""); 
} 


@Override 
protected void onHandleIntent(Intent intent) { 
    registerGCM(); 
} 

private void registerGCM() { 
    Intent registrationComplete = null; 
    String token = null; 
    try { 
     InstanceID instanceID = InstanceID.getInstance(getApplicationContext()); 
     token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); 
     Log.w("GCMRegIntentService", "token:" + token); 
     //notify to UI that registration complete success 
     registrationComplete = new Intent(REGISTRATION_SUCCESS); 
     registrationComplete.putExtra("token", token); 
    } catch (Exception e) { 
     Log.w("GCMRegIntentService", "Registration error"); 
     registrationComplete = new Intent(REGISTRATION_ERROR); 
    } 
    //Send broadcast 
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); 
} 

} 

にこのクラスを持っていますが、私はこの方法registerGCM(呼び出そう)それは私にこのことを示していエラー

06-29 18:00:39.611 5494-5539/com.cisaApp.adrian.cisaappacueductos E/AndroidRuntime: FATAL EXCEPTION: IntentService[] 
                       Process: com.cisaApp.adrian.cisaappacueductos, PID: 5494 
                       java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar) 
                        at com.google.android.gms.iid.zzd.zzdL(Unknown Source) 
                        at com.google.android.gms.iid.zzd.<init>(Unknown Source) 
                        at com.google.android.gms.iid.zzd.<init>(Unknown Source) 
                        at com.google.android.gms.iid.InstanceID.zza(Unknown Source) 
                        at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source) 
                        at com.cisaApp.adrian.cisaappacueductos.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:34) 
                        at com.cisaApp.adrian.cisaappacueductos.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:27) 
                        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) 
                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                        at android.os.Looper.loop(Looper.java:135) 
                        at android.os.HandlerThread.run(HandlerThread.java:61) 

あなたのエラーのために特別にライン

InstanceID instanceID = InstanceID.getInstance(getApplicationContext()); 

答えて

0

IncompatibleClassChan geErrorは、threadによれば、クライアントコードを再コンパイルせずにライブラリに互換性のないバイナリ変更を加えたことを意味します。この問題の詳細については、上記のリンクをお読みください。

あなたの問題を解決するには、関連するSO questionの解決策に従うことができます。このエラーを解決するには、gradle依存関係ツリーを使用してみてください。

実行gradle -q app:dependencies --configuration compileと、このようなエントリの出力チェック:

+--- com.mcxiaoke.viewpagerindicator:library:2.4.1 
| \--- com.android.support:support-v4:+ -> 24.0.0-beta1 (*) 

はまた、これを解決するために、最新のバージョンに依存関係を更新します。