2

I am having a problem to make my Android application build.

I have one Main application module, and another one that is needed for the google-play-services_lib.

My folder structure is as follows:

ParkingApp
   | 
   |-----> google-play-services_lib (Library Project) 
   |-----> ParkingApp
   |-----> settings.gradle

My settings.gradle file is as follows:

include ':ParkingApp', ':google-play-services_lib'

My ParkingApp has the following build.gradle.

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android'

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

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 17
    }
}

And the google-play-services_lib has the following build.gradle:

buildscript {
    repositories {
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.4'
    }
}
apply plugin: 'android-library'

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

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 17
    }

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

Any help is appreciated!

3
  • 2
    it would help if you explained what the problem was.
    – RaB
    May 26, 2013 at 14:55
  • See my answer here: stackoverflow.com/a/16671865/768690
    – Frohnzie
    May 26, 2013 at 15:54
  • @Frohnzie I saw your answer, but I get the same problem. E/dalvikvm: Could not find class 'com.google.android.gms.maps.MapFragment', referenced from method com.example.MainActivity.onCreate May 27, 2013 at 16:42

2 Answers 2

6

With the new updates in Android Studio and Gradle, I think a better solution for adding support package and google play services jars is to use the maven repositories instead of adding the library it self, here is how you can add both to any .gradle file, using this way you will no have more problems adding both to dependent projects.

dependencies {
    compile 'com.google.android.gms:play-services:3.1.36'
    compile 'com.android.support:support-v4:13.0.+'
}

Note: In the new version of Android Studio 0.2.0, you will need also to update the gradle verison to:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
0

Put google-play-services.jar in MyParkingApp/libs and reference it as a dependency from MyParkingApp/build.gradle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.