Error:(42, 30) error: package com.google.android.gcm does not exist

Error:(42, 30) error: package com.google.android.gcm does not exist

我已经从 sdk 安装了 gcm,但之后它也无法正常工作并出现此错误。

C:\Users\name\projectname\app\src\main\java\com\projectname\act\Login.java
    Error:(42, 30) error: package com.google.android.gcm does not exist
    Error:(124, 3) error: cannot find symbol variable GCMRegistrar
    Error:(127, 3) error: cannot find symbol variable GCMRegistrar
    Error:(358, 12) error: cannot find symbol variable GCMRegistrar
    Error:(362, 4) error: cannot find symbol variable GCMRegistrar
    Error:(365, 8) error: cannot find symbol variable GCMRegistrar
    Error:(462, 4) error: cannot find symbol variable GCMRegistrar
C:\Users\name\projectname\app\src\main\java\com\projectname\act\ServerUtilities.java
    Error:(17, 30) error: package com.google.android.gcm does not exist
    Error:(63, 17) error: cannot find symbol variable GCMRegistrar
    Error:(105, 13) error: cannot find symbol variable GCMRegistrar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.

google播放服务也导入了 下面是我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.vibrantmeetme.act"
    minSdkVersion 11
    targetSdkVersion 21
}

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:21.0.3'

}

如果有人有解决办法请给出

尝试将导入中的 com.google.android.gcm 替换为 com.google.android.gms.gcm

在我的例子中,我必须使用:

compile 'com.google.android.gms:play-services-gcm:7.8.0'

所以我必须明确引用 gcm 模块