Although we recommended that you call Google Workspace APIs from a server using server-side authentication, these APIs can also be called using the Android SDK.
Follow the following guides to setup an Android project with the Google API Client Library for Java.
Prerequisites
- A Google account.
- Android Studio SDK 1.2 or later.
- Android SDK packages for API 23 or later, including the latest versions of Google Repository, Android Support Library and Google Play Services.
Prepare the Project
In your Android project, include a build.gradle
file with dependencies such
as these:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.google.android.gms:play-services-auth:15.0.1'
compile 'pub.devrel:easypermissions:0.3.0'
compile('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-<API>-<VERSION>') {
exclude group: 'org.apache.httpcomponents'
}
}
Be sure to replace the API
and VERSION
with the
Google Workspace API and version. For
example, the Google Slides API would have the target
compile 'com.google.apis:google-api-services-slides:v1-rev294-1.23.0'
.
Once the service is authenticated, executing the API call is the same as shown in any of the Google Workspace Java quickstarts.