4

The latest update to Android studio does not allow one to access the project structure GUI from a project that uses gradle. Although I have configured the gradle script to use google play services, for some reason I am still unable to use the library. Here is what I did:

  1. Created a new Android project
  2. Created a folder named "libraries" in the root directory of the project
  3. Copied the google-play-services folder into "libraries" and renamed it to "google-play-services"
  4. Created a build.gradle file in the "google-play-services" folder with the following contents:
apply plugin: 'android-library'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}

dependencies {
    compile files('libs/google-play-services.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion '17.0.0'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aild.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

5.) Edited my project's build.gradle with the following:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
    compile project(':libraries:google-play-services')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 17
    }
}

6.) Changed my settings.gradle to the following

include ':Rimatyo', ':libraries:google-play-services'

Everything compiles fine, but I cam unable to access any Google play services class from my project. All the guides I've seen online utilize the project structure GUI, which isn't possible anymore. What am I missing?

EDIT: Was able to get around the problem by importing a google play service sample app posted by Xavier Ducrohet in the adt-dev Google group and refactoring everything to make it match my project structure. Not ideal, but everything is working.

Alexander
  • 3,037
  • 6
  • 24
  • 17

2 Answers2

9

There is now official support for Google Play services.

jonasb
  • 1,847
  • 1
  • 17
  • 15
0

Could you try building the project first from the command line and then importing it into Studio? If that works, then you are hitting this bug: https://code.google.com/p/android/issues/detail?id=55784

Siva Velusamy
  • 2,471
  • 17
  • 9