LoginSignup
1
0

More than 5 years have passed since last update.

Support Libraryを23から24にしたときのPlay Servicesのエラー

Last updated at Posted at 2016-12-03

layout_dodgeInsetEdgesが使いたかったのでSupport Libraryを23から24にしてみたところ、(GCMの処理で)IncompatibleClassChangeErrorというエラーが発生。これはGoogle Play services 9.0.1で修正されていたため、そちらも更新が必要になった。

Google Services Gradle Pluginを3.0に

build.gradle
buildscript {
    ...
    dependencies {
        ....
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

app/build.gradleの修正。
Google Services Gradle Pluginの行を最後に移動する。これは、利用するGoogle Play servicesのバージョンを確定させてからプラグインを実行する必要があるため。

app/build.gradle
def support_library_version = '24.2.0';
def play_services_version = '10.0.1';    // 9.0.1以上
...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:$support_library_version"
    compile "com.android.support:design:$support_library_version"
    ...
    compile "com.google.android.gms:play-services-gcm:$play_services_version"
}
apply plugin: 'com.google.gms.google-services'

app/google-services.jsonの修正。
再生成するのが良いが、おそらくapi_keyを足せばビルドできる。

app/google-services.json
{
  ...
  "client":[
    {
      ...
    "api_key":[
      {
        "current_key":"AI......"
      }
    ],
    ...
}

フレーバーでpackage nameを変更しているときは、google-services.jsonもフレーバー毎に用意しなければならなくなった。
例えばdebugの場合はapp/src/debug/google-services.jsonを用意する。

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0