Reputation: 153
I am trying to display the Google map on Android. When I load the activity i get a grey screen with the Google logo displayed in the bottom left corner. This happens using the virtual emulator and on a real device too. I have tried using a different Api key but get the same problem. I am using the Map activity provided by Android studio.
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="">
<uses-feature
android:name="android.hardware.sensor.stepcounter"
android:required="true" />
<uses-feature
android:name="android.hardware.sensor.stepdetector"
android:required="true" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gfs.permission.READ_GSERVICES" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".Activities.LandingActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".UserAccountActivities.ProfileActivity" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="redacted" />
<activity
android:name=".Activities.MapsActivity"
android:label="@string/title_activity_maps" />
</application>
</manifest>
Logcat in Error mode
01-02 15:06:24.913 17090-17160/E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
01-02 15:06:24.923 17090-17160/ E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: ***
Android Application (<cert_fingerprint>;<package_name>): ***;
Upvotes: 0
Views: 4161
Reputation: 314
go to Google console and try to enable maps sdk for android...
Upvotes: 1
Reputation: 76589
try to change the hardware-sensors to not required:
<uses-feature
android:name="android.hardware.sensor.stepcounter"
android:required="false"/>
<uses-feature
android:name="android.hardware.sensor.stepdetector"
android:required="false"/>
and also this permission is not required anymore, for years:
<uses-permission android:name="com.google.android.providers.gfs.permission.READ_GSERVICES" />
and the problem actually stems from:
apply plugin: "com.google.gms.google-services"
which has to be moved to the very bottom of the file.
Upvotes: 0