Google Maps API v2 does not work with release key - android

I've tried for about a week to solve this problem. I have google maps working perfectly fine in debug, but no matter what I do when I package the apk I get this error below
05-21 21:00:21.338 31534-31613/? E/Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
I've run the following command
keytool -list -v -keystore ~/Documents/keys/phillybikeshare.jks -alias "pbs"
on two different keystores, took the SHA1 fingerprint that looks like
F9:DB:33:A2:05:02:80:5A:21:9A:19:E6:8A:E4:C4:XX:XX:XX:XX:XX
and made api keys for the SHA1 in the google developer console. I even double checked to make sure I have a variable in both main/res/values/google_maps_api.xml and debug/res/values/google_maps_api.xml yet still nothing.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.peterchappy.phillybikeshare" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<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" />
<permission
android:name="com.peterchappy.phillybikeshare.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.peterchappy.phillybikeshare.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" >
</uses-feature>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".activities.MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".services.AlarmService"
android:exported="false" >
</service>
</application>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.peterchappy.phillybikeshare"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.mcxiaoke.volley:library:1.+'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:cardview-v7:21.0.+'
}
I have no idea what could be wrong. Any help would be greatly appreciated.

I had the same issue before with my debug and release versions of my app.
I created two entries in Google's developer console.
One for the debug version using the SHA1 value from the debug.keystore
that you can find from your home directory in Windows.
e.g.
C:\Users\<UserName\.android\debug.keystore.
And the other one, release version, is the SHA1 value from the .jks file that you used when you build the signed APK.
They need to match or else you will keep on getting that error.
And lastly, don't forget to clear data and cache when you uninstall the application as that could cause issue sometimes.

Related

Play Store says "can't install this app try again, and if it still doesn't work, see common ways to fix it" after downloading is 100% complete

Play Store says "can't install this app try again, and if it still doesn't work, see common ways to fix it".
I have published UPDATE of my different android apps on play store and it got successfully live as usual. But the thing is that on my Google Play Console all apps' new install were ZERO from past 2,3 days.
Manifest AND Build Gradle: App are attached.
I WANT TO MENTION THAT THE APPS ARE BEING DOWNLOADED FOR 100%, then the below dialogue is displayed.
Message Shown on Each Apps Installation
Below is manifest file:
<?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="com...">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/ime_name"
android:largeHeap="true"
tools:replace="android:icon,android:label">
<activity
android:name="com...Main"
android:screenOrientation="unspecified"
android:label="#string/ime_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PrefActivity"></activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|
screenLayout|uiMode|screenSize|smallestScreenSize" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/ads_application_id"/>
</application>
</manifest>
Build Gradle : App
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-R'
buildToolsVersion '29.0.2'
defaultConfig {
applicationId '...'
minSdkVersion 16
targetSdkVersion 29
versionCode 4
versionName '4.43'
}
lintOptions {
abortOnError false
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation 'junit:junit:4.13'
implementation project(':lib')
implementation project(':library')
implementation 'com.google.android.gms:play-services-ads:19.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}
I don't have answers for you, but would like to help you debug this issue. If you have a device that reproduces the problem, try connecting it to your ADB and reading through the error logs what is happening when you get this message. In my case it was something like:
Submitter: commit error message INSTALL_FAILED_UPDATE_INCOMPATIBLE:
Package signatures do not match previously
installed version; ignoring! Task Failed: tid:1000000026,
statusCode:6004
com.google.android.finsky.installerv2.InstallerException: Status: 6004
This made me conclude that there was nothing wrong with the update itself. I was just trying to update from the version that Google Play did not sign to the one signed by Google Play. Not to mention it was a false alarm as my users were not dealing with this issue at all.
Hope you guys find your error message and get to fix your problems!

I'm having white map with Could not find class 'android.app.AppOpsManager'

I've build mapActivity before and it worked perfectly and map appeared... I worked on other project to get a map but it didn't work.... I back to my first mapActivity project(which was working perfectly) and lunched again (after removing its map app from my phone) but it didn't worked and give me blank map
there are the erors:
1-Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.internal.zzro.zzg
2- Could not find class 'android.app.AppOpsManager', referenced from method rv.a
3- Authentication failed. Timeout while trying to contact the server.
and thid in Manifest:
<?xml version="1.0" encoding="utf-8"?>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<permission
android:name="com.example.asus.myapplicationhello.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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="com.example.asus.myapplicationhello.permission.MAPS_RECEIVE"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:largeHeap="true"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="#string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
and this is the gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.asus.myapplicationhello"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
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:24.2.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:multidex:1.0.0'
}

Google Api Key Missing

I am trying to launch an android wearable with an emulator, but it crashes on startup and getting the following error:
 
java.lang.RuntimeException: API key not found. Check that <meta-data android:name="com.google.android.geo.API_KEY" android:value="your API key"/> is in the <application> element of AndroidManifest.xml
But the weird part is i did defined it in my manifest like this:
New editted that "works"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wearfare.wearapp.gpswear"
android:versionCode="1"
android:versionName="1.0" >
<!-- Mark this app as an Android Wear app. -->
<uses-feature android:name="android.hardware.type.watch" />
<!-- Permission required for ambient mode to keep the application running. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault" >
<!-- API key for the Android Maps API v2. The value is defined as a string resource. -->
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxxxxxxxx"/>
<!-- Reference the wearable shared library required to support ambient mode. -->
<uses-library android:name="com.google.android.wearable" android:required="false" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
EDIT 2
I am getting the following:
10-07 10:04:43.972 1614-1614/com.wearfare.wearapp.gpswear W/ResourcesManager﹕ Asset path '/system/framework/com.google.android.wearable.jar' does not exist or contains no resources.
10-07 10:04:43.993 1614-1631/com.wearfare.wearapp.gpswear I/GMPM﹕ App measurement is starting up
10-07 10:04:43.995 1614-1631/com.wearfare.wearapp.gpswear E/GMPM﹕ getGoogleAppId failed with status: 10
10-07 10:04:43.995 1614-1631/com.wearfare.wearapp.gpswear E/GMPM﹕ Uploading is not possible. App measurement disabled
EDIT build.gradle
apply plugin: 'com.android.application'android {
signingConfigs {
}
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.wearfare.wearapp.gpswear"
minSdkVersion 22
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'])
compile 'com.google.android.support:wearable:1.3.0'
provided 'com.google.android.wearable:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:8.1.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-maps:8.1.0'
}
xxx is the api key i put in, but still getting the same error message when running the project. any suggestions what i am missing here?
Thanks in advance.
ALMOST THERE
Ok Guys, it looks like it does work, but it doesnt show my map, it's a grey field. I figured out i can dismiss the app when i longpress it.
So maybe it could be something else why it isnt showing my map?
I think the problem of the grey screen is that you didn't obtain the API key correctly. Please ensure that you have obtained the key correctly. I've had this exact problem when my key was generated for release instead of debug mode.
https://developers.google.com/maps/documentation/android-api/start#obtaining_an_api_key
I have checked your manifest and found problem in it.
Please add </manifest> tag at the end of the file.

Google Maps api2 with Android Studio issue

Using Eclipse I converted several Google Maps v1 to v2 without many problems. One of my services uses the V1 GeoPoint class a great deal and I was able to use the code unaltered by importing import com.google.android.maps.GeoPoint. I have a half dozen apps running maps V2 with using this GeoPoint class.
Now I'm over on Android Studio converting my last maps V1 app to maps V2 but even though I have the same import statement I'm getting an exception at at run time when I reference the GeoPoint class. Saying...
NoClassDefFoundError: Failed resolution of: Lcom/google/android/maps/GeoPoint.
So the same code runs fine when testing in Eclipse but blows when testing in Android Studio.
EDIT: The GeoPoint class compiles fine in AS it just blows at run time. I don't know what would cause this.
If it helps I include my manifest file and the module Build.gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.deanblakely.mttTrial"
minSdkVersion 10
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':library')
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.code.gson:gson:2.2.2'
compile 'com.google.android.gms:play-services:+'
}
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.deanblakely.mttTrial"
android:versionCode="22"
android:versionName="2.22" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="21" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name="com.deanblakely.mttTrial.PSActivity"
android:configChanges="orientation|keyboardHidden"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar" >
</activity>
<activity
android:label="#string/app_name"
android:name="com.deanblakely.mttTrial.LicenseCheck"
android:theme="#android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<uses-library android:name="com.google.android.maps" />
</activity>
<service
android:name="com.deanblakely.mttTrial.StalkService"
android:exported="false" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="not the actual key" />
<!--' Release key is not the actual release key'-->
<!--' Debug key is not the actual debug key'-->
</application>
<!-- Required permission to check licensing. -->
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
</manifest>
Improve your build.gradle
compile 'com.google.android.gms:play-services:5.0.89'
And add this your Manifest
<uses-permission android:name="com.deanblakely.mttTrial.permission.MAPS_RECEIVE" />

Android Studio 0.4.2 and Google Map api v2 - Error contacting Google servers

I spend some hours tring to make a new project with AS 0.4.2 and the result is again a blank map with three errors:
E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
E/Google Maps Android API﹕ Ensure that the following correspond to what is in the API Console: Package Name: com.demomap, API Key: AIzaSyBiYMhCKkRR-rqScAQgbetmVCCBZusgvcE, Certificate Fingerprint: DC37F5B58C2526B6FF8A6A72F8AB7A81D90F0779
E/GetJar SDK [com.zeptolab.ctr.ads]﹕ Usage: UsageRollupDatabase: collectAppSessionEvent() Failed to find or create a reporting window for an event with timestamp 1389656136587, giving up...
E/GetJar SDK [com.zeptolab.ctr.ads]﹕ Usage: UsageRollupDatabase: collectAppSessionEvent() Failed to find or create a reporting window for an event with timestamp 1389656136845, giving up...
E/Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors)
This is what I changed in build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
}
and here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<permission
android:name="com.demomap.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.osman.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".BasicMapActivity" android:label="#string/app_name" />
<activity android:name=".LegalInfoActivity" android:label="#string/app_name" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBiYMhCKkRR-rqScAQgbetmVCCBZusgvcE" />
</application>
My app was working correctly wast week and now I don't know what is wrong. Tried to change the key several times and still nothing - only blank map and that message.
If I remove that line from the manifest:
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
the app is crashing with this:
Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
Is there anyone who has dealt with a similar problem?

Categories

Resources