Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play Services in an Android Studio 0.1.1 gradle project?

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.

like image 443
Alexander Avatar asked Jan 14 '23 06:01

Alexander


1 Answers

There is now official support for Google Play services.

like image 100
jonasb Avatar answered Jan 25 '23 05:01

jonasb