在 android studio 中使用 GCMRegistrar 没有失败

without fail useing GCMRegistrar in android studio

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':jLibUtils')
    compile files('libs/androidmarketapi-0.6.jar')
    compile files('libs/jsoup-1.7.3.jar')
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
}

另外,我想写"import com.google.android.gcm.GCMRegistrar"。如果我写source "import com.",没有google选项。我找不到并写下那个

如何在 android studio 中使用这些 gcm 类?.?

使用 android 中的最新 GCM 仅使用以下代码或 class 在您的应用中注册 GCM。

package com.bhadresh.Activity;

import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.google.android.gms.gcm.GoogleCloudMessaging;
import com.google.android.gms.iid.InstanceID;
import com.bhadresh.Other.Constant;
import com.bhadresh.R;

/**
 * Created by windws on 07-Jul-15.
 */
public class RegistrationIntentService extends IntentService {
    private static final String TAG = "RegistrationIntentService.class.getSimpleName();";


    public RegistrationIntentService() {
        super(TAG);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

        try {
            synchronized (TAG) {
                InstanceID instanceID = InstanceID.getInstance(this);
                String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
                SharedPreferences settings =
                        getSharedPreferences("" + Constant.PREFRENCE_NAME, MODE_PRIVATE);
                SharedPreferences.Editor editor = settings.edit();
               // Log.d("device token", token);
                editor.putString("deviceToken", token);
                editor.commit();

            }
        } catch (Exception e) {

        }
        // Notify UI that registration has completed, so the progress indicator can be hidden.
        // LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(getString(R.string.intent_name_REGISTRATION_COMPLETE)));
    }
}