SparkyNZ
SparkyNZ

Reputation: 6676

Adding Google Drive support to Android project

I want to include Google Drive support in my application, using Android Studio 3.0.1

I have the following entries in my app' build.gradle file:

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

When I try to do a Gradle build I get the following error:

enter image description here

When clicking on "Install Repository and sync project" I then get the following error:

enter image description here

Is the syntax of my dependencies section wrong?

Google shows use of the implementation directive instead of compile but doesn't work for me either.

I've tried changing the play-services-drive line to this:

compile 'com.google.android.gms:play-services-drive:+'

but then I get a load of resource errors that I've never seen before. This project built and ran before I started trying to add the Google imports below:

enter image description here

Errors:

enter image description here

Upvotes: 1

Views: 697

Answers (1)

dominicoder
dominicoder

Reputation: 10185

Did follow step 4?

If you receive an error, check that your top-level build.gradle contains a reference to the google() repo or to maven { url "https://maven.google.com" }.

You would put this in your top-level build.gradle file like so:

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

Google's Play Services are often horribly documented. You should consult their demo project as a better reference as to how to use the APIs (that's where the sample code is from). Hope that helps!

Upvotes: 1

Related Questions