Google Api Key Missing - android

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.

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!

My application is having trouble on real devices

I have finish my application and run it perfectly on my emulator (Nexus 6 API 22). But when I try to run it on a real device, I have troubles, in the first device (with version 5) I have tried crash when I start an activity that implements google maps. At first I try to solve it by set it my key to the release folder as well as on the debug one, but the keep crashing. I thought was about some permissions or dependencies, but I thing I have everything right.
My build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "jocadoci.soloordena"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.android.support:design:25.0.0'
compile 'com.paypal.sdk:paypal-android-sdk:2.14.2'
compile 'com.android.support:multidex:1.0.1'
}
And the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jocadoci.soloordena">
<uses-permission
android:name="jocadoci.soloordena.android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="25" />
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"
android:maxSdkVersion="25" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="25" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="25" />
<uses-permission
android:name="android.permission.INTERNET"
android:maxSdkVersion="25" />
<uses-permission android:name="mypackage.android.permission.MAPS_RECEIVE"
android:maxSdkVersion="25" />
<application
android:allowBackup="true"
android:icon="#mipmap/soloorndenalogo"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity" />
<activity android:name=".MapsItaly"/>
<activity android:name=".ListViewCheckboxesActivity"/>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".DrawerActivity"
android:label="#string/title_activity_drawer"
android:theme="#style/AppTheme.NoActionBar">
</activity>
</application>
Then I try on another device (this one was with version 4.2.2), in this device just doesn't want to start, crashed when you tried to open it. I tried to change the version on my compileSDKVersion between 24 and 25 but look that is not that the problem. At this moment I don't know what else do, I thought also that was because my application use a google service should be post it already on google play, I did it but also did not work.
I will appreciate anyone who could help me.
Thanks in advance.
P.S: If someone want to try the app is in the store already but looks that only is available in Mexico, but if some one want to try it I could send my app-release.apk
UPDATE
First thanks all of you for give the time to answer. I appreciate.
Thanks to #Windsor answer came to me the doubt about using the same API key for the debug and release file. Looking about my sha-1 key and on the google development website I realize that indeed I could use the same API key for both files (debug and release) but the think was that with the generated signed key that I create building my apk I could use the sha-1 to add one more restriction to my API key and could use it to the app-release.apk. Successful the app run correctly on a real device (version 5), but unfortunately keep stopped on others version devices.
hello can you cheked Location Permision for API level 23?
Generate a signed apk.
Make sure you have your sha1 release key on Google API services. Does debug work on real devices?
Can't tell you without seeing the main activity.
If you api key isn't working normally you just don't get a map. If it works on multiple android versions in a emulator ods are api key. Debug keys don't work in the final copy you need to generate a apk with the release key!!!
Could be you method for getting location services.
I build for the lowest target version test then add compatibility for newer version that's what I like.

Signed apk has 0 compatibility in google play store

I've been working on a project for some time now and I pretty much finished and am ready to release it to the play store. I was able to deploy my app through debug mode via the USB cable onto my Samsung s4 phone. Strangely, when I generated the signed apk and released it to the play store, I can't download it on my phone... This makes no sense since I was able to use it when I was testing it... I asked my friends and they experienced the same thing. I looked at my developer console and it says my app is compatible with LITERALLY 0 phones in the market... So I looked it up and I thought maybe my manifest is messed up, so here it is (I'm using android studio btw):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="XXXX">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-feature android:name="android.hardware.CAMERA"/>
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication"
>
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
<activity
android:name="XXXX"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
<provider android:authorities="com.facebook.app.FacebookContentProviderXXXX"
android:name="com.facebook.FacebookContentProvider"
android:exported="true" />
</application>
</manifest>
So I see no issues in the manifest (maybe someone can correct me on that) and if there were it wouldn't have ran on my phone when I tested the app.
So I use a lot of external libraries for my app, here is the list:
1) facebook api
2) twitter api
3) snapdragon
4) google play service
I also had to use multidex (as you saw in the manifest) because the code exceeded 64k lines of code. Here's how the build.gradle looks like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xxxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 3
versionName "1.2"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { java.srcDirs = ['src/main/java', 'libs'] } }
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile('com.twitter.sdk.android:tweet-composer:1.0.2#aar') {
transitive = true;
}
}
I'm totally new with gradle so I'm not sure if it's set up correctly so there maybe issues with the gradle itself or maybe something else. Anyone have any suggestions what I can do?
I changed the camera feature to required false in the manifest and that did the trick. When I uploaded the apk in the developer console it said 8k+ devices supported. Also the manifest was inccorect, when you put the use-features tag make sure to have camera all lowercase not uppercase like I had.

Can't use Google Play Services on emulator android studio

I can't use Google Play services with the emulators in Android Studio. I give you my build.gradle and manifest files:
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
repositories {
mavenCentral()
}
defaultConfig {
applicationId "fr.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.android.support:multidex:1.0.1'
}
Part of my AndroidManifest (I don't show all the activities):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:name="android.support.multidex.MultiDexApplication"
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.facebook.sdk.ApplicationId"
android:value="#string/app_id" />
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings" >
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
</application>
</manifest>
And in a xml I just have the google button : com.google.android.gms.common.SignInButton
And when I lauch my Application, when I arrive in the activity containing the button, I have the following message : "the app won't run unless you update Google Play services". I also have (I tried some solutions) "this app won't run without Google Play services, which are missing from your phone".
I've found some questions on this problem, but it always said that the last emulator don't have this problem. But using the default Nexus 5 (API 22) emulator on android studio gives me these errors. So I tried to install the last apk google play services file, and after successing the install, I launch the app and have this time this error : "the app relies on Google play services, which is not supported by your device. Contact the manufacturer for assistance." I also tried with a virtual device that I created, with API 22 and 23 and I have the same errors.
I don't understand because I thought that the errors with Google play services didn't exist anymore on the last API.
Thanks for help.
Maybe try to create emulator with image x86 which includes Google APIs

Google Maps API v2 does not work with release key

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.

Categories

Resources