Reputation: 988
I am using google Maps in my android application. I have created the key and added necessary permissions in manifest file:
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com..."
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="com....MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<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="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key"/>
<activity
android:name=".activities.MainActivity"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
google-maps-api.xml:
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">
AIzaSyAjGQ-...
</string>
Also, I have added the following depedency compile 'com.google.android.gms:play-services:8.4.0'
to compile, which is working:
app.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com..."
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
}
I have also added google-services.json
to PROJECT_NAME/app/:
But when the app is started, I get this message in debugger:
GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
I have followed steps on this link, but regarding my case, what could I miss to configure?
Upvotes: 1
Views: 2019
Reputation: 11245
You need to place the configuration file generated by this Link.
Then you need to Get Configuration file From This and Download it file named
google.json
.Then you need to put that file into your project at app/ or mobile/ directory of your
Android
.And as you need to add
apply plugin: 'com.google.gms.google-services'
exact below ofapply plugin: 'com.android.application'
as in MD's answerBuild.Gradle
file.
After that Build->Clean
your project.
And make sure you have string resource available with API_KEY in it named
<string name="google_maps_key">Your Api Key</string>
.
Upvotes: 0
Reputation: 47817
I think
build.gradle
:apply plugin: 'com.google.gms.google-services'
build.gradle
:classpath 'com.google.gms:google-services:1.5.0-beta2'
For more information Check this
New build.gradle
looks like
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com..."
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services:8.4.0'
}
Upvotes: 3
Reputation: 171
i had the same issue. i tried to solve it.but no luck.if you have backup project use that one.
Upvotes: 0