错误:包com.google.android.gms.appstate不存在

时间:2015-10-08 11:35:01

标签: android android-studio google-play-services

由于此错误无法编译我的android项目。

/BaseGameUtils/src/main/java/com/google/example/games/basegameutils/GameHelper.java
Error:(32, 39) error: package com.google.android.gms.appstate does not exist
Error:(293, 28) error: cannot find symbol variable AppStateManager
Error:(294, 30) error: cannot find symbol variable AppStateManager
Error:Execution failed for task ':BaseGameUtils:compileReleaseJava'.
  

编译失败;请参阅编译器错误输出以获取详细信       信息:BUILD FAILED

我的gradle ..

apply plugin: 
'android-library' repositories 
{ 
   mavenCentral() 
} 
buildscript 
{ 
  repositories
  {
     mavenCentral()
  }
  dependencies
  { 
     classpath 'com.android.tools.build:gradle:1.0.0'
  }
}
dependencies
{ 
    compile 'com.android.support:appcompat-v7:20.0.+' 
    compile 'com.android.support:support-v4:20.0.+' 
    compile 'com.google.android.gms:play-services:+' 
} 
android 
{ 
   compileSdkVersion 21 
   buildToolsVersion '21.0.0' 
   defaultConfig 
   { 
      minSdkVersion 14 
      targetSdkVersion 23 
   } 
   productFlavors { } 
}

4 个答案:

答案 0 :(得分:4)

我看到你没有指定护目镜播放服务库。

而不是这个

compile 'com.google.android.gms:play-services:+'

试试这个

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

注意:您可能有不同的版本,而不是7.8输入。

答案 1 :(得分:1)

Bump,就我而言,我使用的版本太高了:

    compile "com.google.android.gms:play-services:10.2.1"

我把它改为:

    compile "com.google.android.gms:play-services:7.+"

虽然有效,但我不知道为什么不包含7 {7}以上版本中的appstate

答案 2 :(得分:0)

首先,您应该检查/ extras / google / google_play_services / libproject / google-play-services_lib>存在。

其次,您在build.gradle中添加代码

compile 'com.google.android.gms:play-services:5.+'

答案 3 :(得分:0)

您缺少com.google.android.gms.appstate包。你应该把它添加到你的应用程序。为此,将compile 'com.google.android.gms:play-services:5.+'添加到build.gradle(Module:app)。