I've updated my Android SDK and also the PlayServices Library. Nothing seems to work right now.
我已经更新了我的Android SDK以及PlayServices Library。现在似乎没什么用。
The import com.google.android.*; does not exists, and I've added the 'compile' lines on the Gradle File.
导入com.google.android。*;不存在,我在Gradle文件中添加了'compile'行。
Have someone experienced this? How can I solve this?
有人经历过这个吗?我怎么解决这个问题?
EDIT
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.code.gson:gson:2.3'
compile 'org.roboguice:roboguice:3.0.1'
compile 'com.google.android.gms:play-services:7.3.0'
}
That's the Gradle File for a Module.
这是模块的Gradle文件。
2 个解决方案
#1
If you use Android Studio and want to use the latest Google libraries via Gradle dependency, you will have to update the
如果您使用Android Studio并希望通过Gradle依赖项使用最新的Google库,则必须更新
You can do this via Tools -> Android -> SDK Manager -> You have to update the stuff under Extras
您可以通过工具 - > Android - > SDK管理器 - >您必须更新Extras下的内容
Also make sure that you are not using the Offline Mode of Gradle. You can find this option via (I did this on a Mac) Android Studio -> Preferences -> Gradle -> (Global Gradle Settings) Offline Work
还要确保您没有使用Gradle的离线模式。您可以通过(我在Mac上执行此操作)Android Studio - >首选项 - > Gradle - >(全局Gradle设置)离线工作找到此选项
Make sure this option is not checked.
确保未选中此选项。
Something which was mentioned by @CommonsWare already (and i add it just to sum up this answer) is to sync the project via the Gradle files. You can do this via the toolbar as seen here:
@CommonsWare已经提到的东西(我只是为了总结这个答案而添加它)是通过Gradle文件同步项目。您可以通过工具栏执行此操作,如下所示:
Or via the menu Tools > Android > Sync Project with Gradle Files
或者通过菜单工具> Android>使用Gradle文件同步项目
If nothing of the above is working for you, it would be really helpful if you can try to build the project via the command line or the terminal with the following command:
如果上述任何内容都不适合您,那么如果您可以尝试使用以下命令通过命令行或终端构建项目,那将非常有用:
gradle clean build --debug
and then post the output here. It will hopefully show why it can't resolve the library.
然后在这里发布输出。它将有希望说明为什么它无法解析库。
#2
Try Tools > Android > Sync Project with Gradle Files and see if that clears up your problem. There's a bug where Android Studio does not always warn you to do this with the yellow banner on the editor.
尝试工具> Android>使用Gradle文件同步项目,看看是否能解决您的问题。有一个错误,Android Studio并不总是警告您使用编辑器上的黄色横幅来执行此操作。
#1
If you use Android Studio and want to use the latest Google libraries via Gradle dependency, you will have to update the
如果您使用Android Studio并希望通过Gradle依赖项使用最新的Google库,则必须更新
You can do this via Tools -> Android -> SDK Manager -> You have to update the stuff under Extras
您可以通过工具 - > Android - > SDK管理器 - >您必须更新Extras下的内容
Also make sure that you are not using the Offline Mode of Gradle. You can find this option via (I did this on a Mac) Android Studio -> Preferences -> Gradle -> (Global Gradle Settings) Offline Work
还要确保您没有使用Gradle的离线模式。您可以通过(我在Mac上执行此操作)Android Studio - >首选项 - > Gradle - >(全局Gradle设置)离线工作找到此选项
Make sure this option is not checked.
确保未选中此选项。
Something which was mentioned by @CommonsWare already (and i add it just to sum up this answer) is to sync the project via the Gradle files. You can do this via the toolbar as seen here:
@CommonsWare已经提到的东西(我只是为了总结这个答案而添加它)是通过Gradle文件同步项目。您可以通过工具栏执行此操作,如下所示:
Or via the menu Tools > Android > Sync Project with Gradle Files
或者通过菜单工具> Android>使用Gradle文件同步项目
If nothing of the above is working for you, it would be really helpful if you can try to build the project via the command line or the terminal with the following command:
如果上述任何内容都不适合您,那么如果您可以尝试使用以下命令通过命令行或终端构建项目,那将非常有用:
gradle clean build --debug
and then post the output here. It will hopefully show why it can't resolve the library.
然后在这里发布输出。它将有希望说明为什么它无法解析库。
#2
Try Tools > Android > Sync Project with Gradle Files and see if that clears up your problem. There's a bug where Android Studio does not always warn you to do this with the yellow banner on the editor.
尝试工具> Android>使用Gradle文件同步项目,看看是否能解决您的问题。有一个错误,Android Studio并不总是警告您使用编辑器上的黄色横幅来执行此操作。