I am trying to Google map API.
when I run my Emulator it is show this:
what i can do??
To the edited Question
Google maps require google play services installed.
You cannot runs maps on Emulator because emulator do not have google play services apk installed.
Quoting docs
If you want to test your app on the emulator, expand the directory for
Android 4.2.2 (API 17) or a higher version, select Google APIs, and
install it. Then create a new AVD with Google APIs as the platform
target.
You require emulator of Andorid 4.2.2 or higher with google api's as the platform
Note :The below answer is to the question before the Edit. OP changed
the question completely.
You are missing a meta tag in your manifest file
<application
android:allowBackup="true"
android:icon="#drawable/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" />
...// rest of the code
Also you have
<uses-sdk
android:minSdkVersion="8"
So you should be using SupportMapFragment instead of MapFragment.
So change this
android:name="com.google.android.gms.maps.MapFragment"
to
android:name="com.google.android.gms.maps.SupportMapFragment"
Also extend FragmentActivity instead of Activity.
You can also get rid of the below. Not required
<permission
android:name="com.mapee.googlemapapi.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mapee.googlemapapi.permission.MAPS_RECEIVE" />
Related
After much looking around SO and other places and not being able to fix my problem I will now create a new post in the hopes of getting my problem resolved.
I am putting together a test app to obtain a location using Google play services and seem to have everything in place - including the permissions. When the test app is run via the emulator,, an error stating that the client must have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permissions. Below is a piece of the stack trace.
11-19 16:34:40.403: E/AndroidRuntime(1245): Caused by: java.lang.SecurityException: Client must
have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to perform any location
operations.
And here is part of AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.ACCESS_COURSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
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>
</application>
What else? I am using the Google APIs platform 5, api 21 for my build target and have the google-play-services... library added to the project. I have also set-up mock latitude and longitude values on the DDMS' Emulator Control tab.
Is there anything else that needs to be put in place to get this to work? Can this be run from the emulator? For what it is worth, the project being worked with is the LocationUpdates project that was downloaded from Google.
If you need additional information to help point me in the right direction please let me know.
Thank you.
I'm not sure why you get permission errors even though your permissions are in the manifest file but I can already tell you that Google Play Services won't work on the emulator unless you're using Google API
See here
To develop an app using the Google Play services APIs, you need to set up your project with the Google Play services SDK. If you haven't installed the Google Play services SDK yet, go get it now by following the guide to Adding SDK Packages.
To test your app when using the Google Play services SDK, you must use either:
A compatible Android device that runs Android 2.3 or higher and includes Google Play Store.
The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher.
EDIT:
Oh wow, I have just noticed that this post is already quite old. If that's a problem someone please tell me or delete the post
The error:
08-15 12:59:17.435: E/Google Maps Android API(14665): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
The Google Console:
The manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cefetmgrdctcc.sgtp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.cefetmgrdctcc.sgtp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.cefetmgrdctcc.sgtp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Hidden key"/>
<activity
android:name="com.cefetmgrdctcc.sgtp.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>
The layout of the map control:
<fragment
android:id="#+id/googlemap"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
I've imported the Google Play Services into my project and marked on the Google API Console Services list "Google Maps API v2", "Google Maps API v3" and "Google Maps Android API v2", however it seems my Map Fragment is still not being able to authenticate.
Map Fragment is just a blank grey square on the middle of the screen, any ideas why is this happening?
Hi I was just having this exact same problem. I tried everything the docs said but nothing seemed to work.
The only thing that worked for me was uninstalling and reinstalling my application (not even rebooting worked) because apparently if you make one mistake on the configuration the system caches the failed authentication and your maps won't work even after fixing your configuration.
So try following the docs and guides on configuring Google Maps Api on Android but every time you change something on your configuration uninstall and reinstall.
If you are running application on a device,experiencing the same issue and had no luck any other solutions.
make sure the installed google-play services is the latest one.
make sure the device date and time is correct as well
http://www.techkhoji.com/no-connection-retry-google-play-store/
Google Play Services sync with their master servers to send and
receive data, to do this your device time and date should be correctly
set
Check if other applications depend on google-play services such as Play Store are working.If they are having trouble with connecting to servers ("NO CONNECTION, RETRY") even when the internet connection is available one of the above points could be the solution.
I regenerated API key and updated in google console, its working fine
Real beginner's question:
My university group are working on an Android project. We're hosting it on an repository. I tried to download a version but I can't get it working.
I have Eclipse 32Bit installed, with the latest version of the JDK. I have the Android SDK Manager installed, with Android SDK Tools, Android SDK Platform-Tools, Android 4.2.2(API 17), Android 4.1.2(API 16) and all the extras installed.
To begin with, I was getting an error "Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties." I did this but it didn't fix anything. I found an alternative fix on Google which suggested I right click the project and go to properties. Then, go to Java Compiler, choose Enable Project Specific Settings and choose a lower compliance level. I did this and set it to 1.6.
I've read that something could be missed from the Android Manifest but I honestly don't know what. This is a copy of it:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.csc7045project"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="16" />
<permission
android:name="com.csc7045project.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.csc7045project.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<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="com.csc7045project.EventActivity"
android:label="#string/app_name" >
<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.maps.v2.API_KEY"
android:value="AIzaSyCvdEysH-5FQeiNDiiXFBd25iZLtZYIdUY"/>
</application>
</manifest>
In the main code of the project, the issue all seems to resolve around GoogleMaps. There is a variable GoogleMap map, and all references to the variable map in the code are errors. I do have the Google APIs downloaded through the SDK Manager.
I'd appreciate any advice on how to fix it so I can start to contribute. Additionally, I should point out at this stage that the project does work on other machines, so it's not an error with the code.
Edit: When I run, I get the following 18 errors (some of these errors are repeated multiple times):
CameraUpdateFactory cannot be resolved
CameraUpdateFactory cannot be resolved
GoogleMap cannot be resolved to a type
LatLng cannot be resolved to a type
MapFragment cannot be resolved to a type
Marker cannot be resolved to a type
MarkerOptions cannot be resolved to a type
OnMarkerClickListener cannot be resolved to a type
Edit 2:
From the errors you receive it seems like you handled you first problem:
Android requires compiler compliance level 5.0 or 6.0. Found '1.7'
now you problem is derived from the fact that classes that are related to Google Map API V2 can't be found by the compiler. this problem will occur when you don't perform the Google Map API V2 referencing correctly.
please head to this guide I wrote on how to properly integrate Google Maps in your application and follow the first three steps to get an idea of how it's done correctly:
Google Maps API V2
Hey I am trying to use Google Maps on my emulator even though I've installed Google Play Services library when I run the app it says
This app won't run without Google Play Services which are missing from your phone
on LogCat I get the warning about it but not really sure why I am getting this.
my MainActivity.java
package com.mapsmaps;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GoogleMap mapa = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapsmaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<permission
android:name="com.mapsmaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mapsmaps.permission.MAPS_RECEIVE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />F
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
>
<activity
android:name="com.mapsmaps.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBdbj4iXi0SijKjJDrJw5RigtSpQcaID7Q" />
</application>
</manifest>
LogCat -
D/dalvikvm(451): DexOpt: couldn't find field
Landroid/content/res/Configuration;.smallestScreenWidthDp
W/dalvikvm(451): VFY: unable to resolve instance field 24
D/dalvikvm(451): VFY: replacing opcode 0x52 at 0x0012
D/dalvikvm(451): VFY: dead code 0x0014-0018 in
Lcom/google/android/gms/common/GooglePlayServicesUtil;.b
(Landroid/content/res/Resources;)Z
W/GooglePlayServicesUtil(451): Google Play services is missing.
W/GooglePlayServicesUtil(451): Google Play services is missing.
W/GooglePlayServicesUtil(451): Google Play services is missing.
W/GooglePlayServicesUtil(451): Google Play services is missing.
W/GooglePlayServicesUtil(451): Google Play services is missing.
W/GooglePlayServicesUtil(451): Google Play services is missing.
W/GooglePlayServicesUtil(451): Google Play services is missing.
"To test your app when using the Google Play services SDK, you must use The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher."
From http://developer.android.com/google/play-services/setup.html
To test your app when using the Google Play services SDK, you must use either:
A compatible Android device that runs Android 2.3 or higher and includes Google Play Store.
The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher.
Please check the link http://developer.android.com/google/play-services/setup.html
there is clearly mentioned that you must provide a physical development device on which you can run and debug your app.
Note: Google Play services is not supported on the Android emulator — to develop using the APIs, you need to provide a development device such as an Android phone or tablet.
As of now Google Maps V2 are not going to be displayed on Emulators. They will be running only on Real Time Devices which have play store app installed. Test the Application that having Google Maps V2 only on Real time device and not Emulators. There is no other alternative also as of now.
Google Maps V2 isn't meant to work on an emulator since it is bundled with the Google Play Services.
If you're still wondering how to make it work on the emulator, you might want to give this blog post and SO answer a read. As pointed out by CommonsWare, the tweaks listed in these article boil down to pirating software. If you're really thinking about developing on Android, you might wanna consider buying a device.
I've faced this problem before. The reason is your google play is work on your emulator. Try this to install google play to your emulator
You can check this blog post I wrote on how to run Google Maps API V2 on the emulator:
Emulator speed-up and Google Map API V2
It is an information that I found here on SO in one of the posts.
Start the SDK manager and install the Google API images (are currently 2).
Then create an AVD based on either of them. You should be good to go :)
I'm trying to build the official android google map api v2 sample on a (gingerbread 2.3.5) phone .
I added android-support-v4.jar to official sample project.
I took the sample from the official tutorial in <android-sdk>/extras/google-play-services/samples/maps
I copied the sample app in Eclipse, reference the google-play-services_lib project as an Android library, and build the whole thing with the Android SDK 4.1.2 (api 16).
Unfortunately, ahen I launch the app the map is blank and I don't have any exception or message.
The only thing I got are those suspicious lines in the logcat :
Unable to resolve superclass of Lmaps/a/du; (411)
Link of class 'Lmaps/a/du;' failed
Unable to resolve superclass of Lmaps/a/ej; (2363)
Link of class 'Lmaps/a/ej;' failed
Unable to resolve superclass of Lmaps/j/k; (2379)
Link of class 'Lmaps/j/k;' failed
ERR Could not find class 'maps.j.k', referenced from method maps.y.ae.a
VFY: unable to resolve new-instance 3571 (Lmaps/j/k;) in Lmaps/y/ae;
I suspect that my project structure in eclipse 3.8 is somewhat messed up.
I tried the following things (even the most idiotic) to no avail.
1. Invalid api key ?
I generated a "debug.keystore" with keytool and updated the eclipse preference (Android/Build/Keystore).
Of course, I registered that new keystore/SHA1 and get a new api key that I used in the AndroidManifest file
2. Wrong project target ?
I tried to build my two projects with the following targets :
Android 4.2.1
Google Api 4.2.1
3. adding google-play-services_lib as a project dependency
I tried to add google-play-services_lib as a project dependency on top of being added as an android library in the demo build path.
And tick the matching export checkbox.
4. test google maps api v2 on the phone
I downloaded trulia real estate app that is said to use the v2 api on the phone to be sure that the phone is compatible with the new api
Here is the manifest for the sample app
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapdemo"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- End of copy. -->
<application
android:hardwareAccelerated="true"
android:icon="#drawable/ic_launcher"
android:label="#string/demo_title" >
<!-- You must insert your own Google Maps for Android API v2 key in here. -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="XXXXXXXX" />
<activity android:name=".MainActivity" >
<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/basic_map" />
<activity
android:name=".CameraDemoActivity"
android:label="#string/camera_demo" />
<activity
android:name=".EventsDemoActivity"
android:label="#string/events_demo" />
<activity
android:name=".GroundOverlayDemoActivity"
android:label="#string/groundoverlay_demo" />
<activity
android:name=".LayersDemoActivity"
android:label="#string/layers_demo" />
<activity
android:name=".LocationSourceDemoActivity"
android:label="#string/locationsource_demo" />
<activity
android:name=".MarkerDemoActivity"
android:label="#string/marker_demo" />
<activity
android:name=".OptionsDemoActivity"
android:label="#string/options_demo" />
<activity
android:name=".PolygonDemoActivity"
android:label="#string/polygon_demo" />
<activity
android:name=".PolylineDemoActivity"
android:label="#string/polyline_demo" />
<activity
android:name=".ProgrammaticDemoActivity"
android:label="#string/programmatic_demo" />
<activity
android:name=".TileOverlayDemoActivity"
android:label="#string/tile_overlay_demo" />
<activity
android:name=".UiSettingsDemoActivity"
android:label="#string/uisettings_demo" />
<activity
android:name=".RawMapViewDemoActivity"
android:label="#string/raw_mapview_demo" />
<activity
android:name=".RetainMapActivity"
android:label="#string/retain_map" />
<activity
android:name=".MultiMapDemoActivity"
android:label="#string/multi_map_demo" />
</application>
</manifest>
Here are some screenshots of my project structure/build path.
I think maybe you make something wrong when you apply the api KEY.
I have the same problem, and at last I found that I turn on the incorrect service. at https://code.google.com/apis/console/,
There are Google Maps API v2 and Google Maps Android API v2.
You should use Google Maps Android API v2.
I had exactly the same problem (all configurations the same, maps.j.k stuff in the logcat). However, for me choosing Google APIs as build target solved it. But that was Google APIs 4.2, so I suggest that you install the update and try with the more recent target.
I resolved this issue by changing de targetSdkVersion with de last targetSdkVersion avaiable, at the AndroiMainfest.xml file.
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
Are you using ProGuard? Usually class names like "a", "b", etc. are a result of ProGuard obfuscating class names, and maybe the Maps API breaks when that happens. If that's the case, you will either have to disable ProGuard or add some -keep lines to your proguard.cfg file. This post shows what those lines might look like.
In my case it was due to 2 issues
on my phone the latest Google Maps app was not installed (in fact there was no google maps at all)
I didnt have all the required permissions set in my manifest
<uses-permission android:name="android.permission.INTERNET"/>
<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"/>
As documented in https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api
http://developer.android.com/sdk/index.html --this is the link for the adt bundle in android..try downloading this and start over again..maybe there's a problem with your ADT.
Check the console API you've enabled Google Maps Android API v2
I was dealing with same issue. I tried to implement the com.example.mapdemo and had a heck of a time.
I copied the code of the BasicMapActivity to a clean new project and made the Libraries look as above.
Basically, I couldn't get either to work. I got the "Authorization failure" error in the debugger.
Then, today, I prepared new keys specifically for each project with the specific com.example.xxx after the semicolon when preparing the key in the Google Console.
I did Project->Clean at every step.
I ran it in debugger first, then just Run. And, if I remember, a few times after making the change to the manifest.
Then, finally, they worked. It seemed, in the end, to require a key for each specific project.
Here's what worked for me. When you use the Google APIs Console to create your API key, be sure to append ;com.example.mapdemo to the SHA1 fingerprint. (I was using something else more appropriate for another app I'm currently developing.) What clued me in on this solution was an authorization error in the LogCat.
In my case I added LocationSource Interface so I can get location data but i forgot to add :
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
at Manifest file.
Don't forget to use separate keys for debug and release version of the app!
If you have already tried everything, try to uninstall and reinstall again your app: on my phone (S3 mini), after the first launch with the wrong key, I corrected it, but it didn't work until a complete uninstallation.
Maybe some sort of caching is used.