问题
Can't compile my android project because of this error.
/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'.
Compilation failed; see the compiler error output for details. Information:BUILD FAILED
My 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 { }
}
回答1:
I see that you have not specified the goggle play services library.
Instead of this
compile 'com.google.android.gms:play-services:+'
Try this
compile 'com.google.android.gms:play-services:7.8.0'
Note: You might have a different version so instead of 7.8 enter that.
回答2:
Bump, in my case I was using too high version:
compile "com.google.android.gms:play-services:10.2.1"
I changed it to:
compile "com.google.android.gms:play-services:7.+"
It worked but I have no idea why isn't appstate
included in versions above 7
回答3:
Firstly you should check that /extras/google/google_play_services/libproject/google-play-services_lib> is exist.
Secondly you add code in build.gradle
compile 'com.google.android.gms:play-services:5.+'
回答4:
You are missing the com.google.android.gms.appstate package. you should add this to your app. for that add compile 'com.google.android.gms:play-services:5.+'
to your build.gradle(Module:app).
来源:https://stackoverflow.com/questions/33014599/error-package-com-google-android-gms-appstate-does-not-exist