Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

The NativeDisplayObjects sample app does not work on Android
Started by Divergent Monkey Dec 11 2018 10:28 AM

- - - - -
11 replies to this topic
native map android
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

Google recently introduced a new API key that is needed to display native map views using the Google Maps API. I have created a key as per the instructions here:

 

https://developers.google.com/maps/documentation/javascript/get-api-key

 

and I got a message that says that the key is valid and ready to use. However, when running my app on an Android device, it does not work. I use build 3440, which should be able to handle this according to the docs.

 

To test this, I created a test API key in the Google Cloud Platform. I then added that key to the Corona NativeDisplayObjects sample app in config.lua as in the docs. I built it and tested it on my Android device but it did not work either.

 

I have create a support ticket at Google but as far as I can see in the Google Cloud Platform, the key is fine. Could this be a bug on the Corona side?

 

Anyone else had this problem?



[TOPIC: post.html]
#2

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

Just checked the device logs (see below) and there is a row that caught my attention:

 

E/Web Console(16533): Uncaught Error: The Google Maps JavaScript API does not support this browser.:109

 

Is the native Map view somehow using a browser "under the hood"? I don't know if this is relevant...

 

 

D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300 (read only)
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300, Prev AP = 300, Duration = 10004
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/STATUSBAR-NetworkController( 2575): onSignalStrengthsChanged signalStrength=SignalStrength: 13 -1 -1 -1 -1 -1 -1 99 -140 -20 -200 -1 2147483647 gsm|lte 0x4 level=4
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300 (read only)
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300 (read only)
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300 (read only)
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
V/AlarmManager( 2359): waitForAlarm result :8
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300, Prev AP = 300, Duration = 10000
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/STATUSBAR-NetworkController( 2575): refreshSignalCluster: data=0 bt=false
D/STATUSBAR-IconMerger( 2575): checkOverflow(288), More:false, Req:false Child:2
D/STATUSBAR-NetworkController( 2575): onSignalStrengthsChanged signalStrength=SignalStrength: 14 -1 -1 -1 -1 -1 -1 99 -140 -20 -200 -1 2147483647 gsm|lte 0x4 level=4
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/STATUSBAR-NetworkController( 2575): refreshSignalCluster: data=0 bt=false
D/STATUSBAR-IconMerger( 2575): checkOverflow(288), More:false, Req:false Child:2
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300 (read only)
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
I/GATE    (16533): <GATE-M>DEV_ACTION_COMPLETED</GATE-M>
E/Web Console(16533): Uncaught Error: The Google Maps JavaScript API does not support this browser.:109
D/LocationManagerService( 2359): getProviders()=[passive, gps, network]
D/SSRMv2:Monitor( 2359): SIOP:: AP = 300 (read only)
I/Finsky  (15340): [1347] com.google.android.finsky.bo.an.run(6): Stats for Executor: BlockingExecutor com.google.android.finsky.bo.ao@4260e848[Running, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 7]


[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,471 posts
  • Enterprise

What device are you testing on that's generating this error?

 

Rob



[TOPIC: post.html]
#4

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

A Samsung Galaxy S3.



[TOPIC: post.html]
#5

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

I did some further research (i.e. googling) on this and it seems that this happens every now and then as Google phases out support for older browsers. A number of systems/platforms/frameworks appear to be affected by this and I'm guessing they all access the maps via some sort of "browser emulation"... (again, I'm just guessing)

 

Could this be the case here too? If so, does something need to be updated internally in Corona in order to make the native Map object work on Android again?



[TOPIC: post.html]
#6

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

@Rob:

 

Just heard from Google support:

 

 

Right now, we don't have any issues with Google Maps JavaScript API, so it is unlikely that your map is not loading due to some issue on our side. If you are having error messages from the API itself, that means, there's something wrong with the setup.

 
When I checked your project in the cloud console, I can see that there are no issues with the setup and the API key should be ready to use.
 
However, I can also see here that even if you mentioned that you created the API key recently, the project XXX up to now, does not have any usage at all. There should be some, if you are testing your application, because the dashboard of cloud console is supposed to show the number of request, regardless if it's an error request or a success.
 
The possible issue here is that your API key is not being applied to the request even if you have already added it to the application that's why the request to the API is not being logged to your project. Or the application is getting an error and does not really reach the part where the map should be called, that's why there are no requests that are being logged.


Given the above (and the fact that the app works on iOS), this seems to me like a bug somewhere in Corona.



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,471 posts
  • Enterprise

On iOS, we use Apple's map SDK. On Android, we use a Google JavaScript-based map inside of a webView. We do this instead of using the Google Map SDK so that maps will work on Kindle Fires (and at the time Nook devices). It's possible that the browser identifying information is showing that the webView is too old for Google Maps.

 

This may be relevant: https://developers.google.com/maps/faq#browsersupport

 

 

Android

  • The current version of Chrome on Android 4.1+.
  • Chrome WebView on Android 4.4+.

 

The minimum supported SDK is level 15 which is 4.03. Based on this, its likely maps would be unsupported on anything less that 4.4 which is API level 19.  You can try setting the minimum SDK level in your build.settings:

 

http://docs.coronalabs.com/guide/distribution/advancedSettings/index.html#minimum-sdk-version

 

and set it to 19 and see if that solves the issue.

 

Rob



[TOPIC: post.html]
#8

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

I checked the software versions on the device:

 

Android version: 4.3.0
Chrome: 70.0.3538.110
 
That means that the Chrome version is ok but not the webView version. If I understand things correctly then, it simply means that the Android version is too old causing the webView version to be too old in turn. Is that correct?


[TOPIC: post.html]
#9

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,471 posts
  • Enterprise

Yes, Android 4.3 would be too old for Google Maps to work in a webView.



[TOPIC: post.html]
#10

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

Ok, thanks!



[TOPIC: post.html]
#11

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

After testing with a brand new device, it still does not work on Android (although workging perfectly on iOS). Google support wrote this:

 

 

It looks like you are having issues adding the API key to the JavaScript Map request, so it does not authenticate under your project. If you are not able to add an API key in your Map request, or you have an invalid character in your request (like a space or when URL encoded, it could be a plus sign (+), or any special character), or you accidentally added an extra character or deleted a portion of the key, you will have an error for invalid key. The error will result to a grey map with "Oops! ----" message.

 
To fix this, we would need to get the exact request that your application generated. Is there a way for you to log the full URL request that your application is sending?

 

 

I sent the key to Google support and they have confirmed that it is correct and I have re-checked in config.lua, which is also correct. This is what it looks like

license = {
        google = {
            key = "[my google iap key]",
            mapsKey = "[my google maps key]",
        }
    }

"key" is for Google IAP and "mapsKey" is for showing maps (as per the new requirement from Google). Google specifies the word "key" to add the maps key when making a request to the Google Maps API:

  <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
  type="text/javascript"></script>

Could it be that you are using the "key" string and not the "mapsKey" string when making the call?

 

 

This looks more and more like something on Corona's end. My key is valid and it is entered correctly at the correct place according to the docs. Does the Corona NativeDisplayObjects sample app work for you? If adding the Google IAP key too?



[TOPIC: post.html]
#12

Divergent Monkey

[GLOBAL: userInfoPane.html]
Divergent Monkey
  • Contributor

  • 293 posts
  • Corona SDK

I'm moving this discussion to a new thread in the Android forum since it is no longer just a matter of the sample app but of the native map object on Android in general. 




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: native, map, android