There doesn't seem to be a shortage of solutions available for getting Google Play Services to work using Android Studio. I’ve tried most of them. After much trial and much error I’ve come to the conclusion that in order for many of these solutions to work you must have the exact combinations of versions as the authors of these solutions. This magic combination seems to have a very real effect on how successful you will be with any given solution. I believe that I have not found the solution for the versions of software that I am using, but haven’t ruled out the chance I have missed something simple/stupid so please be gentle.
So here is my setup and hopefully someone will be able to see the problem: I always start from scratch. That way I know I don’t have any lingering sludge from an older version that would mess with me. I am using Android Studio (Preview) 0.4.2, gradle 0.7 (per build.gradle file), and am trying to use Google Play Services 4.0.30 so that I can use Google Maps V2.
I have opened the SDK Manager and have downloaded every update and verified that I have all the SDK tools loaded, all of API 19 loaded (and many of the lower versions loaded including 14, and all of the Extras loaded including the Support Repository, Support Library, and Google Play Services. Basically I’ve erred on the side of over-downloading.
With this configuration I can:
import com.google.android.gms.*
but no .maps or anything else so no GoogleMap etc.
I’ll show the contents of some key files. Sorry for the length but there may be something hiding in a place I wouldn’t expect and I wouldn’t want to ‘not show’ the problem. So please bear with me. ...And if someone needs to see more please let me know too. Thx
My build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
dependencies {
// Google Play Services
compile 'com.google.android.gms:play-services:4.0.30'
// Support Libraries
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.android.support:gridlayout-v7:19.0.0'
compile 'com.android.support:support-v13:19.0.0'
}
My proguard-rules.txt:
-keep class * extends java.util.ListResourceBundle {
protected Object[][] getContents();
}
# Keep SafeParcelable value, needed for reflection. This is reqd to support backwards
# compatibility of some classes.
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
public static final *** NULL;
}
# Keep the names of classes/members we need for client functionality.
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
@com.google.android.gms.common.annotation.KeepName *;
}
# Needed for Parcelable/SafeParcelable Creators to not get stripped
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
My AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.klhsoftware.k4wmapp" >
<permission
android:name="com.klhsoftware.k4wmapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.klhsoftware.k4wmapp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true">
<activity
android:name="com.klhsoftware.k4wmapp.MapScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="LocationsContentProvider"
android:authorities="in.wptrafficanalyzer.locationmarkersqlite.locations"
android:exported="false" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIza<myValue>-tsldkfjdOM" />
</application>
</manifest>