【问题标题】:Android app backward compatible version of google play services APIAndroid 应用向后兼容版本的 google play services API
【发布时间】:2016-09-13 13:09:54
【问题描述】:

当我在 android mobile 版本 4.4 (lollipop) 上部署我的 android 应用程序时,我收到一条消息“除非您更新 Google Play 服务,否则应用程序将无法运行”

我查看了我的 android 手机,可以看到 Google Play 服务版本是 5.1.89。我知道在我的代码中我使用的是 8.4.0

我不希望 android 向用户显示弹出窗口以更新 google play 服务

任何 android 移动应用专家都可以帮我解决这个问题。 如何在不要求用户更新谷歌服务的情况下使我的应用向后兼容?

我的build.gradle如下

  apply plugin: 'com.android.application'

  android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

buildTypes {
    debug {
        debuggable true
    }
}
        defaultConfig {
    applicationId "com.me"
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dexOptions {
    preDexLibraries = false
}
packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
lintOptions {
    checkReleaseBuilds false
}

  }

 dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:cardview-v7:23.0.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'

}

【问题讨论】:

  • 这是不可避免的。否则降级你的版本,虽然这会牺牲一些功能并且那些旧的错误会再次出现。
  • 尝试在您的build.gradle 中添加compile 'com.google.android.gms:play-services:5.0.+'
  • 如果我设置为 5.0.+,我的应用程序是否可以在带有 Google 服务 8.4.0 的 Marshmallow 版本的 Android 手机上运行?
  • 嗨 Enzokie,如果我降级,我的应用会在 8.4.+ 的 google play services 的更高版本的 android 上运行吗?
  • 嗨 Indramurari,我尝试使用 5.0.+ 进行编译,但出现错误。我看起来需要提供正确的版本名称,例如 5.0.89 。当我查看 /m2repository/ 时,我的计算机中没有 5.0.89 版本。如何下载 google play 5.0.89

标签: android android-gradle-plugin google-play-services google-maps-android-api-2 mobile-application


【解决方案1】:

Google Play Services overview 中所述,该服务由两部分组成:在构建时链接到应用程序的客户端库,以及客户端库使用进程间连接到的 Google Play 服务 APK通信 (IPC)。

如果您希望使用 Google Play 服务的新功能,或者遇到在更高版本中修复的错误,您通常只需要升级客户端库。

Google Play 服务 APK 作为后台服务运行,为您的应用程序提供实际的 Google 服务。借助这种拆分模式,Google 可以及时向最终用户设备推出新功能、服务更新和关键错误修复,而无需等待运营商或设备制造商实施这些修复。

因此,Google Play 服务 APK 必须向后兼容之前发布的客户端库版本,以避免在每次更新时破坏开发者的应用程序。

然而,事实并非如此。如果您使用特定版本的客户端库构建应用程序,则安装的 Google Play 服务 APK 版本不得低于该版本。

因此,如果您针对库版本 5.1.89 构建,您的应用将适用于 APK 的 8.4.0 版本,但如果安装的版本是 5.0.0,则不会。

如 Google Play 服务 setup guide 中所述,行为良好的应用程序始终会在访问服务之前检查已安装的 Google Play 服务 APK 的可用性和版本。当最终用户被提示在设备上更新 Google Play 服务时,这正是您所看到的,这是您作为应用程序开发人员可以做的最好的事情,因为您无法在最终用户的设备上强制更新,并且另一种方法是让您的应用程序崩溃。

【讨论】:

  • 因此,它不向后兼容,为什么你为一个非常简单的问题解释了这么多?
猜你喜欢
  • 2022-07-22
  • 2015-11-12
  • 1970-01-01
  • 2020-03-21
  • 1970-01-01
  • 2019-08-20
  • 2020-02-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多