AndroidStudio emulator "won't run unless you update Google Play Services" - java

I have this problem with my emulator, i'm using API 5.1.1 and i have the lastest version of Google Play Services from SDK Manager.
AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
In the build.grable:
compile 'com.google.android.gms:play-services:+'

Navigate to settings--> apps in your emulator and then find Google Play Services, check the version number and use it in you build.gradle
Hope this helps

Change the SDK in your emulator to v21 or lower. Physical devices are not effected by this issue.
The reason Android is complaining about an update for Google Play services is related to a known issue in Android emulators for API v22 and up (at this time 23). https://code.google.com/p/android/issues/detail?id=176348
You should try to use the latest version of Play Services in your build script as users are generally forced to have the latest version of this on their device.

This problem occurred when I start my application on emulator Android 5.1.1 (x86_64) - API 22. I have read some discussions about it, but no one from them helped me.
I tried to adjust version of Google Play Services in gradle build script (I mean you should update the script with "app" name). Don't forget to sync gradle when you update something in your script.
My gradle script "app" after updates:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.itmm.map"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
Please, have a look into dependencies section. You're interesting in the follwoing line of script:
compile 'com.google.android.gms:play-services:9.0.0'
Currently, ver. 9.0.0 helps me and everything is ok. I can see MapActivity on Android emulator. 9.0.0 is not a newest version of Google Play Services (the newest is 9.6.1), but it works and it can solve your problem, if you aren't interestion in new features of ver. 9.6.1.

I had the same issue. But I followed the following things
1) First download the latest build tools and play services in Android SDK
Android Studio -> Tools -> Android -> SDK Manager -> SDK Tools -> Android SDK Build Tools -> Install them
& install Play Services by following same steps
2) Create a new emaulator with latest api level for ex( API level : 28)
3) Run the app in the latest emulator
It will work fine.

I downgraded the SDK from 5.1 to 5.0 and it's working.

Your build.gradle has this line:
compile 'com.google.android.gms:play-services:+'
This means that android will use the latest version of Google Play Services when ever the app is run. The emulator might not have all the latest updates so the app will not run. Updating Google Play Services will help.

My issue was resolved after logging in with an google account on the emulator. The 'update' button worked after that

Encountered the same problem on Android Studio 2.2. What I did was to go to SDK Manger -> Launch Standalone SDK Manager, uninstalled Broken Intel x86 Atom google_apis. Restarted Android Studio and ran the project, a popup asked Download System Image, hit OK to continue, the problem then went away.

Since I haven't seen any working solutions in 2020. There are two ways to fix this:
Easy way is to create a new emulator with PlayStore Enabled. Check before downloading system image for the emulator.
Hard way is to to install Google Play Store on the emulator manually and make the update button work. You can refer to the installation part here.
After that, the app will automatically update the Google Play Services in a few minutes. That's all.
Note: If that doesn't work, Go to Chrome -> Search for Google Play Services and open the playStore link of that app and update it there.

Check in your SDK settings if youve installed google play services:
Android Studio--System Settings--Android SDK--SDK Tools:
Look for:Google Play Services and Google Play Licensing Library and make sure that both their status is:Installed.....if the above checklist is perfect,the next step you ought to perform is:
Open your build.gradle project level gradle and check that your gradle has:
classpath 'com.google.gms:google-services:3.1.0'
Then in your App level gradle:
Under dependencies:
dependencies{
implementation 'com.google.android.gms:play-services-auth:11.8.0'
and at the end of your gradle file:
repositories {
mavenCentral()
apply plugin: 'com.google.gms.google-services'
}
Next
Click on the notification error you keep getting in your notification bar of your emulator and sign in with your google account(existing Email Address and password)
Then try and run the app again...if you still get the error,click the notification error and try to sign in,,,keep trying until eventually the google playstore app will install and prompt you to update it.
This is the simplest process,it requires a little bit of patience but evetually it works.
Good Luck

my emulator's Google Play services version is 12.6.85
so I changed the build.gradle like:
implementation 'com.google.android.gms:play-services-maps:12.0.1'
Notes:
to check emulator's Google Play services version: go to Emulator \ Settings \ Apps \ GooglePlay services
to see available versions for the build.gradle check https://developers.google.com/android/guides/releases

Related

Android project error

I am trying to run an app that has a Google Maps Activity on my phone. My phone's running on Android 4.1.3 and the Minimum SDK for my project is API 15: Android 4.0.3
I just created the project on Android Studio and tried to run it on my phone. But it won't run and I am keep getting this error. Can someone tell me how to solve this?
That error probably means that you are using too much libraries. And because you are trying to use google maps I'm guessing you included everything google.
Try to just use the libraries you need.
For maps use this:
dependencies {
com.google.android.gms:play-services-maps:9.2.1
}
Reading material:
https://developers.google.com/android/guides/setup
You need to configure your gradle for multidex.
Modify the module-level build.gradle file configuration to include the support library and enable multidex output, as shown in the following code snippet:
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
See more on same link which you are refering : https://developer.android.com/studio/build/multidex.html#mdex-gradle
You can also see some related question for same error:
How to enable multidexing with the new Android Multidex support library
Android java.exe finished with non-zero exit value 1

How to add latest goole play service android application in older version phone?

I integrate firebase in my android application. Firebase will support the google play service from 9.0.0 version . I used google play service for map in the application. When i install the app in the phones that have the lower version of 9.0.0 play service,The app won't run unless update the google play service
These are the codes that i added for fire base . And i added a json file that get during firebase integration.
packagingOptions {
exclude 'META-INF/LICENSE-FIREBASE.txt'
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.firebase:firebase-core:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
I think this documentation can help you with your problem. This link will serve you as a guide on how to set up properly the Google Play Services.
Open the build.gradle file inside your application module directory.
Add a new build rule under dependencies for the latest version of play-services. For example:
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.2.0'
}
There is a list of Google Play services API and their corresponding description in build.gradle in the link above for you to follow.
Save the changes and click Sync Project with Gradle Files in the toolbar.
Then, that's it, you can now begin developing features with the Google Play services APIs.

Android Studio Gradle cannot find 'com.android.support:design:22.2.0' (the Android Design Support Library)

This issue has been incredibly frustrating for me for the past two weeks.
Using the Android SDK Manager, I updated the following:
Tools:
Android SDK Tools rev. 24.3.3
Android SDK Platform-tools rev. 22
Android SDK Build-tools rev. 22.0.1
Android 5.1.1 (API 22):
SDK Platform rev. 2
Google APIs rev. 1
Sources for Android SDK rev. 1
Extras:
Android Support Repository rev. 16
Android Support Library rev. 22.2.1
Google Repository rev.22
This is the exact list of all the repositories that I've installed and updated to with the Android SDK Manager.
However, when I attempt to add the line:
compile 'com.android.support:design:22.2.0'
Gradle becomes stuck on addDependecies. Furthermore, when I go to Module Settings, and then to Dependencies, when I try to add a new library, the 'com.android.support:design:22.2.0' does not appear within the list!
Here's additional information about my target, compile, and minimum SDK version:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.myandroidapplication.newtestapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
What could I possibly be missing at this point? Thank you!
You have to use version 22.2.1 as it has installed on your computer.
compile 'com.android.support:design:22.2.1'
For me, I was initially adding the support library dependency by typing it out in the build.gradle of my app directly.
I cleaned the line that I had typed and added the dependency through the android studio GUI,
Go to File
Choose Project Structure
Click on the Dependencies tab
Click on the + symbol in the upper right conner and choose Library Dependency.
Search for and add the support library in the dialog that appears
Gradle build/sync should start automatically.
Don't know why, but it works for me at least.

Android studio - Failed to find target android-18

I have a problem with Android Studio 0.2.3.
When I run my project the build stops and appears message that says:
Gradle: Execution failed for task ':AppName:compileDebugAidl'.
> failed to find target android-18
although I have installed the SDK platform of Android 4.3 (API 18) and I tried to reinstall all the SDK. I've also added the ANDROID_HOME variable in the system variables.
What seems to be the source of this error?
I think you might not have the Android-18 sdk installed. Go to Tools > Android > SDK Manager and check to see if Android 4.3 (API 18) is installed.
I solved the problem by changing the compileSdkVersion in the Gradle.build file from 18 to 17.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
}
dependencies {
compile 'com.android.support:support-v4:13.0.+'
}
STEP 1) Start Android SDK Manager
With android command something as below,
$ /usr/local/android-studio/sdk/tools/android
STEP 2) Find API 18
STEP 3) Select Android 4.3 (API 18 ) and install packages.
What worked for me in Android Studio (0.8.1):
Right click on project name and open Module Settings
Verify SDK Locations
Verify Gradle and Plugin Versions (Review the error message hints
for the proper version to use)
On the app Module set the Compile SDK Version to android-L (latest)
Set the Build Tools version to largest available value (in my case
20.0.0)
These changes via the UI make the equivalent changes represented in other answers but is a better way to proceed because on close, all appropriate files (current and future) will be updated automatically (which is helpful when confronted by the many places where issues can occur).
NB: It is very important to review the Event Log and note that Android Studio provides helpful messages on alternative ways to resolve such issues.
Thank you RobertoAV96.
You're my hero. But it's not enough. In my case, I changed both compileSdkVersion, and buildToolsVersion. Now it work. Hope this help
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ..
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
If you had the problem, opened SDK manager, installed the requested updates, returned to Android Studio and had the problem again, IT IS RECOMMENDED TO RESTART ANDROID STUDIO befor trying anything else.
Gradle will run automatically and chances are that your problem will be over. You will very possibly be told install the appropriate SDK TOOLS package, which is found in your SDK MANAGER under the second tab (sdk's are not the same as sdk tools, they are complementary packages).
You don't even need to hunt the tools package, if you click on the link under the error message, Android Studio should call SDK Manager to install the package automatically.
Restart Android Studio again and you should be up and running much faster than if you attempted workarounds.
RULE OF THUMB> restart your application before messing with options and configurations.
Check the local.properties file in your Studio Project. Chances are that the property sdk.dir points to the wrong folder if you had set/configured a previous android sdk from pre-studio era.
This was the solution in my case.
I had the same problem when trying out Android Studio. I already had projects running on the ADT under SDK 18. No need to hack the manifest files.
Fixed by:
export ANDROID_HOME= pathtobundle/adt-bundle-linux-x86_64-20130729/sdk
If you don't have the ADT installed, and just want the SDK, it seems like a good solution is to install everything and then point Android Studio to the just the packaged SDK.
cd pathtobundle
wget http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20130729.zip
unzip *.zip
As someone else said, you may need to run the SDK Manager to install the desired packages before running Studio.
I've had a similar problem occurr when I had both Eclipse, Android Studio and the standalone Android SDK installed (the problem lied where the AVD Manager couldn't find target images). I had been using Eclipse for Android development but have moved over to Android Studio, and quickly found that Android Studio couldn't find my previously created AVDs.
The problem could potentially lie in that Android Studio is looking at it's own Android SDK (found in C:\Users\username\AppData\Local\Android\android-studio\sdk) and not a previously installed standalone SDK, which I had installed at C:\adt\sdk.
Renaming Android Studio's SDK folder, in C:\Users... (only rename it, just in case things break) then creating a symbolic link between the Android Studio SDK location and a standalone Android SDK fixes this issue.
I also used the Link Shell Extension (http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html) just to take the tedium out of creating symbolic links.
This will also happen if you have written compileSdkVersion = 22 e.g. (as used in the "new new" Android build system) instead of compileSdkVersion 22.
You can solve the problem changing the compileSdkVersion in the Grandle.build file from 18 to wtever SDK is installed ..... BUTTTTT
If you are trying to goin back in SDK versions like 18 to 17 ,You can not use the feature available in 18 or 18+
If you are migrating your project (Eclipse to Android Studio ) Then off course you Don't have build.gradle file in your Existed Eclipse project
So, the only solution is to ensure the SDK version installed or not, you are targeting to , If not then install.
Error:Cause: failed to find target with hash string 'android-19' in: C:\Users\setia\AppData\Local\Android\sdk
Target with hash string 'android-18' is corresponding to the SDK level 18. You need to install SDK 18 from SDK manager.

Android Studio 0.2 App that use Google Maps - Gradle modify

I'm developing an App in Android studio. And I want use a Google maps API, but I can't use UI to configure project settings. I tried some different instruction to add maps, but it didn't work. I have to modify somehow build.gradle file? Can you tell me how? Does someone have experience with that?
Thanks for every advice.
If you are on 0.2 it means that you already have Google Repository and Android Repository installed(from Android SDK: terminal$ android sdk).
One of them, has the Google Play services.
Here is a full build.gradle for your module:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
Notice how(easily) the play services can be included.
Also gradle version is 0.5.+ so it can be auto updated!
Also another VERY important thing, that wasted me a lot of time is the minimum sdk version!
It must be 8 or above, since google play services aren't supported for lower versions!

Categories