我已经从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.
谷歌播放服务也是导入的
这是我的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'
}
如果有人有解决方案,请提供
答案 0 :(得分:4)
在我的情况下,我不得不使用:
compile 'com.google.android.gms:play-services-gcm:7.8.0'
所以我必须明确引用gcm模块
答案 1 :(得分:0)
尝试在导入中使用com.google.android.gcm
替换com.google.android.gms.gcm