LoginSignup
13
13

More than 5 years have passed since last update.

【環境構築】GradleでGoogle Play Services対応(Mac, Linux)

Posted at

MAC環境

1. build.gradleに下記の内容を追加

apply plugin: 'android'
...

dependencies {
    ...
    compile 'com.google.android.gms:play-services:+'
}

2. Google Play Servicesのインストール

・Android SDK Managerでインストール
もしAndroid SDK Managerで表示されない場合は
Android SDK ManagerでAndroid SDK Platform-toolsを更新すると表示される

3. gradleでビルド

・Android SDK ManagerでGoogle Repositoryをインストールする
・Android SDK ManagerでAndroid Support Repositoryをインストールする
・./gradlew clean buildを実行

Linux編

1. Android SDKバージョンアップ

$ ./android update sdk --no-ui

2. アップデートリストの確認

$ android list sdk --all

3.Google Play Services, Google Repository, Android Support Repositoryのインストール

$android update sdk -u -a -t 9, 11, 12

4. Progaurdでけっこう苦戦

・ローカル(Mac)で動いてたSDK直下のproguard-android.txtをそのままてデプロイ環境にコピーして使う

エラー対応のまとめ

1. preBuildエラー

Execution failed for task ':preBuild'.
failed to find Build Tools revision 19.1.0

android-sdk-linuxのbuild-toolに19.1.0がない
■Android SDK Build-toolsのインストール番号を確認

android list sdk --all

下記の結果が出る。インストール番号は3番!!

 3- Android SDK Build-tools, revision 20

■Android SDK Build-toolsをダウンロード

android update sdk -u -a -t 3

2. compile 'com.android.support:support-v4:5.0.77でのエラー

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.google.android.gms:play-services:+'
    ...
}

上記のようにバージョンを指定すればOK

3. zipalignのエラー

■Android SDK version 23にはzipalignがデフォルトで入ってないので18からダウンロードして入れる

4. proguardのエラー

java.io.FileNotFoundException: /PATH_TO_SDK/sdk/tools/proguard/proguard-android.txt (No such file or directory)

Android SDK version 23にはproguardがデフォルトで入ってないので18からダウンロードして入れる

13
13
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
13
13