Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps on Android not working on app but demo is fine

I cannot get Google Maps to work on my app.

I see a blank screen; no grids show, only the google logo and the +/- zoom buttons.

What I have done:

  • I have the "Google Maps Android API v2" API enabled
  • I have added my project along with the demo project to the API credential list on Google console
  • I've also added the required permissions for Internet, location, com.google.android.providers.gsf.permission.READ_GSERVICES.
  • Even added the "MAPS_RECEIVE" permission as some posts suggested
  • Also added the 'meta-data' google_play_services_version

Since the demos are working, I literally copied MultiMapDemoActivity and its files into my project and tried opening map, to no avail.

The problem may be linked to this issue. However, it seems like they can't get map to work at all.

Here is the interesting bit that I noticed, I usually get this:

10-02 12:29:20.376: D/REQUEST(5826): Connection opened to:https://clients4.google.com/glm/mmap/api
10-02 12:29:20.376: D/REQUEST(5826): Open Connection

Followed by this:

10-02 12:21:45.361: D/REQUEST(5826): DRD(80): 62|132
10-02 12:21:45.361: D/REQUEST(5826): Close
10-02 12:21:45.361: D/REQUEST(5826): Error processing: com.google.maps.api.android.lib6.b.d@42caa7b8 not retrying
10-02 12:21:45.361: D/REQUEST(5826): Retrying: com.google.maps.api.android.lib6.gmm6.c.a@4296a530
  • Also, not sure if this is relevant, but as soon as I click to open the map, or click on the map after it has opened and is showing a blank view, I see this:

      10-02 13:03:32.978: E/DatabaseUtils(15468): Writing exception to parcel
      10-02 13:03:32.978:/DatabaseUtils(15468): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this   
      requires android.permission.INTERACT_ACROSS_USERS_FULL
    

EDIT #1

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

EDIT #2 Also, the declared package name was com.A.B.C (the manifest); whereas the activities of my project had the structure of com.A.B..

I have since updated my project structure to match that of the manifest, but I still see the same errors as before, nothing changes. I'm really at sea here, since I cannot understand what could be going wrong here.


Some help to resolve this will be appreciated, thanks!

like image 940
Hahn Avatar asked Oct 02 '14 07:10

Hahn


People also ask

Why is Google Maps not working on my Android phone?

Clear the app's cache & data On your Android phone or tablet, open the Settings app . Tap Apps & notifications. Follow the steps on your device to find the Maps app. After you select the app, storage & cache options should be available.

What is wrong with Google Maps app?

There are various reasons why this happens. It's possible the location accuracy option is disabled, you're using an older version of the app, or you don't have proper access to the internet. The Google Maps app itself may have issues, too. Cache files and other app data can sometimes cause various issues with the app.

Why is my Google Maps only showing preview?

When you select the route and only see the preview option, it's because google.com/app passed a starting set of coordinates to the maps app, so your asking google maps to provide directions between two points, not your current location to a point.


2 Answers

It turns out that I had read n-1 questions regarding this issue here. Finally, after continuous searching everywhere, I stumbled upon the answer here by @Jack.

Basically the line:"HttpsURLConnection.setDefaultSSLSocketFactory(...)" was the culprit in my code. I commented it out and everything worked fine.

NOTE: I have not tried to keep the line of code and modify it to make maps work yet. If I need/do it, I'll post a comment.

like image 171
Hahn Avatar answered Sep 24 '22 05:09

Hahn


You need to add your SHA1 fingerprint to the public API access. Go to eclipse > preferences. Android > build and copy your default eclipse SHA1 fingerprint.

Now go to https://console.developers.google.com select your app, 'APIs and auth' > 'credentials' > and click on 'Edit allowed android applications' put your SHA1 figerfirnt like that:

XX:XX:XX:XX:XX...XX;com.your.pakage.app

like image 34
mgonzalez Avatar answered Sep 24 '22 05:09

mgonzalez