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
Related
I applied the exact steps as mentioned in the google developer doc to create an example google map project and everything went fine on the emulator, but in all real device google map doesn't show up not also simple map object only white screen saying google may service are updating.
In gradle dependency
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
Emulator Google play service version 9.6.83(480-133155058)
Samusung j5 Google play service version 10.2.98(438-146496160)
I do have API key and entered in Manifest.
I have tried in real device on google play service version 9.6.83(480-133155058) it works but not for version 10.2.98(438-146496160).
In emulator the maps only works if dependency is
com.google.android.gms:play-services-maps:9.6.0 or less than it.
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:theme="#style/Theme.Bbtechgroup">
<activity
android:name=".ui.activity.MainActivity"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<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"/>
android {
compileSdkVersion 22
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
buildTypes {
debug {
debuggable true
}
release {
debuggable false
minifyEnabled false
signingConfig signingConfigs.keys
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
}
}
configurations {
all*.exclude group: 'gson', module: 'gson'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile 'com.google.android.gms:play-services-maps:9.6.0'
compile 'com.google.android.gms:play-services-gcm:9.6.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:23.1.0'
}
I had the same problem long time ago! i just change one thing and it worked for me. <meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key"/>
instead of referring to string file paste you key here. as
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="bcbcVCHYRKddd88ejj"/>
Try it out once.
In emulator the maps only works if dependency is com.google.android.gms:play-services-maps:9.6.0 or less than it
The Android Studio emulators don't always have the latest Google Play API unless you explicitly update it yourself from an APK or getting the Play Store installed.
The most common reason for a blank map is that your API key isn't correct or some other service request / authentication request is denied in your code.
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.
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.
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.
I have a simple Android Wear app that runs fine on the Gear Live and in the Emulator, and which I'd now like to package into an .apk for distribution.
I'm using Android Studio but am more familiar with Eclipse for Android development, so may have something wrong.
Here is the build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "myApp"
minSdkVersion 20
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:+'
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
wearApp project(':app')
}
and here is the Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myApp" >
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault" >
<activity
android:name="myApp"
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>
The gradle build completes without error: I sign the app with the same keys I use for non-wear apps in the Play Store. Whether I open the created apk file on a device running Android 4.4.4, or a device running 4.3 (the 'phone that's actually in communication with the Gear Live), I obtain the error:
"There is a problem parsing the package"
Initially I assumed that this was because the 'phone was running 4.3, whereas the target/min SDK is 20. But I get the same parse error on a 4.4.4 tablet.
Could anyone suggest what I may have wrong?
On the mobile (phone) app your Min SDK should be 18 with target sdk at 20 since your phone is running 18 (4.3) and your tablet is running 19 (4.4).
On your wear app it should be Min SDK 20.
Also just a gotcha I found is you need to sign both the mobile and wear app's which you may hit next.