私はAndroid Studioを試しています。プロジェクトで Drive API を使用したいと考えています。Eclipse には Eclipse 用の Google プラグインがありますが、Android Studio はどうでしょうか。これまでに試した人はいますか?
7 に答える
以下に、Google ドライブの最新バージョン (2014.12.28) を示します。
//Google Drive API
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.google.api-client:google-api-client-xml:1.18.0-rc'
compile 'com.google.http-client:google-http-client-gson:1.18.0-rc'
compile 'com.google.api-client:google-api-client-android:1.18.0-rc'
compile 'com.google.apis:google-api-services-drive:v2-rev155-1.19.0'
最新バージョンを確認するには、次のリンクを試してください。
https://developer.android.com/google/play-services/setup.html
https://code.google.com/p/google-api-java-client
https://developers.google.com/api-client-library/java/apis/drive/v2
http://mvnrepository.com/artifact/com.google.apis/google-api-services-drive
私は同じ状況にあり、適切な依存関係のセットを見つけて必要なものを除外するために Gradle がどのように機能するかについての情報をここで見つけなければなりませんでした。build.gradle ファイルの依存関係に必要な行は次のとおりです。
// Replace 'dependencies' in your build.gradle file with the following
// or add these to whatever other dependencies you have.
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
}
それらは時間の経過とともに変化し続けるため、物事の変化に応じて更新し続ける要点を作成しました。
Android Studio で動作するように Google ドライブのクイック スタートを変更する記事を書きました。興味がある場合は、ここで見つけることができます
編集: この Gradle インポートは、Google Play Services に統合されたDeveloper Preview Google Drive APIではなく、Google Drive API for Java を使用することです。
Java クライアント ライブラリは Android もサポートしています。ここからダウンロードできます: https://code.google.com/p/google-api-java-client/wiki/APIs#Drive_API
次に、Drive SDK ダウンロードを解凍し、フォルダーをプロジェクトの libs セクションに移動します。例: /Users/-username-/AndroidStudioProjects/MyProject/MyProjectActivity/libs/
この時点で、[ファイル] -> [プロジェクト構造] をクリックし、[ライブラリ] タブをクリックしてライブラリをプロジェクトに追加し、+ 記号をクリックして SDK をプロジェクトに追加できます。
Java 用 Google API クライアント ライブラリの Android 固有の開発手順は、https ://code.google.com/p/google-api-java-client/wiki/Android で読むことができます。
smokybobの答えはうまくいきましたが、いくつかの実験を行ったところ、これもうまくいきました。
dependencies {
compile files ('libs/libGoogleAnalyticsServices.jar')
compile ('joda-time:joda-time:2.3')
compile ('com.google.code.gson:gson:2.2.4')
compile 'com.google.android.gms:play-services:4.1.+'
}
joda-time と Gson はドライブ API とは何の関係もないと推測しています。
私がするときの注意
gradle dependancies
私は得る
+--- joda-time:joda-time:2.3
+--- com.google.code.gson:gson:2.2.4
\--- com.google.android.gms:play-services:4.1.+ -> 4.1.32
\--- com.android.support:support-v4:19.0.1