Android的SDK管理器今天上午通知我,有一个新的谷歌游戏服务发布下载:修订18.所以,我怎么觉得把我的build.gradle文件中的相应的长版本号?我所有的测试设备都在运行5.0.84版本,所以我尝试更新
编译com.google.android.gms:玩-服务:52年4月4日
到
编译com.google.android.gms:玩-服务:5.0.84
但是,这产生了一个错误:
摇篮的MyApp项目刷新失败:找不到com.google.android.gms:玩-服务:5.0.84。通过要求: {我的应用程序} 的摇篮设置
我在运行Android 0.5.2工作室和建设API19(我还没有升级到Android L / API20尚):也许这是个问题?但总的来说,你怎么匹配版本号的SDK管理器中显示(如18)与版本$ C $下build.gradle(例如5.0.84)?
下面是我的全部build.gradle的情况下,它可以帮助:
应用插件:'机器人'
安卓{
compileSdkVersion 19
buildToolsVersion19.1.0
defaultConfig {
的minSdkVersion 14
targetSdkVersion 19
版本code 1
VERSIONNAME1.0
}
buildTypes {
推出 {
runProguard假
proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'ProGuard的-rules.txt
}
}
//避免使用时,杰克逊错误的APK复制重复文件
packagingOptions {
不包括META-INF /许可证
不包括META-INF /注意事项
}
}
依赖{
//被编译com.android.support:support-v4:+'但是这引起编译错误当L SDK发布
编译com.android.support:support-v4:19.1.0
编译文件树(导演:库,包括:['的* .jar'])
//支持谷歌云消息传递
//被编译com.android.support:appcompat-v7:+'但是这引起编译错误当L SDK发布
编译com.android.support:appcompat-v7:19.1.0
编译com.google.android.gms:播放服务:5.0.84
//杰克逊
编译com.fasterxml.jackson.core:杰克逊核心:2.3.3
编译com.fasterxml.jackson.core:杰克逊 - 注释:2.3.3
编译com.fasterxml.jackson.core:杰克逊 - 数据绑定:2.3.3
}
解决方案
OK,我还没有完全设法找到一个到另一个的映射,但是我已经成功也就是看到一个列表退而求其次的播放服务安装在我的开发机器长版本号。
对于Windows,它在 [Android的SDK] \演员\谷歌\ m2repository \ COM \谷歌\机器人\ GMS \播放服务
(其中, [Android的SDK]
是路径到你的Android SDK文件夹)。
在Mac上,它的Android.app包内:浏览到 SDK /演员/谷歌/ m2repository / COM /谷歌/安卓/ GMS /播放服务
最新版本我的机器是5.0.77(不5.0.84),并把在我build.gradle正常工作。
下面的那种事情,你应该在那个位置看到:
Android SDK Manager notified me this morning that there was a new Google Play Services release to download: revision 18. So how do I find the corresponding long version number to put in my build.gradle file? All my test devices are running version 5.0.84, so I tried updating
compile 'com.google.android.gms:play-services:4.4.52'
to
compile 'com.google.android.gms:play-services:5.0.84'
But that resulted in an error:
Gradle 'MyApp' project refresh failed: Could not find com.google.android.gms:play-services:5.0.84. Required by: {my app} Gradle settings
I'm running Android Studio 0.5.2 and building for API19 (I haven't upgraded to Android L/API20 yet): maybe that's the issue? But in general, how do you match a revision number shown in SDK Manager (e.g. 18) with a version code for build.gradle (e.g. 5.0.84)?
Here's my full build.gradle in case it helps:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
// Avoid "Duplicate files copied in APK" errors when using Jackson
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
dependencies {
// Was "compile 'com.android.support:support-v4:+'" but this caused build errors when L SDK released
compile 'com.android.support:support-v4:19.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
// Support for Google Cloud Messaging
// Was "compile 'com.android.support:appcompat-v7:+'" but this caused build errors when L SDK released
compile 'com.android.support:appcompat-v7:19.1.0'
compile 'com.google.android.gms:play-services:5.0.84'
// Jackson
compile 'com.fasterxml.jackson.core:jackson-core:2.3.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.3.3'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.3'
}
解决方案
OK, I haven't quite managed to find a mapping of one to the other, but I've managed the next best thing which is to see a list of Play Services long version numbers installed on my development machine.
For Windows, it's in [android-sdk]\extras\google\m2repository\com\google\android\gms\play-services
(where [android-sdk]
is the path to your Android SDK folder).
On a Mac, it's inside the Android.app package: browse to sdk/extras/google/m2repository/com/google/android/gms/play-services
The latest version on my machine was 5.0.77 (not 5.0.84), and putting that in my build.gradle worked fine.
Here's the kind of thing you should see at that location: