torsdag 12 juni 2014

Android : Importing Google Play Services API in IntelliJ IDEA

I'll be using an gradle built Android module. First create an empty Android project.

Now we need to setup the dependecies,
This first way is the easy way, edit the 'build.gradle' in the DriveTest directory and add:
dependencies {
    compile ''
    compile ''

Lastly open the AndroidManifest.xml for the Android module and add the following as a child under the <application> tag:
<meta-data android:name=""
                   android:value="@integer/google_play_services_version" />

Afterwards you should be able to auto-complete the dependencies in the IDE.

Another way is to copy the file from 'sdk\extras\google\m2repository\com\google\android\gms\play-services\4.4.52\play-services-4.4.52.aar' to your android modules lib folder then update your build.gradle scripts with the following :
repositories {
                dirs 'libs'
dependencies {
    compile ':play-services:4.4.52@aar'

Troubleshooting :
Make sure you have the following installed in the Android SDK.

Be sure to check min-sdk version in your AndroidManifest.xml and build.gradle files. 9 at least.

Remember that Google Play Services work inside the emulator these days, just make an AVD that runs the Google APIs with version 4.2.2 and above. Just be sure to sign the application, i use the command line when installing a signed package as IDEA has no auto-installation when building. (what i've found)

Quickest route for me, uninstalling my debug installation first. Then installing the signed release.