CartoDB / mobile-sdk

CARTO Mobile SDK core project
https://carto.com/docs/carto-engine/mobile-sdk/
BSD 3-Clause "New" or "Revised" License
185 stars 67 forks source link

Failed to decode tile in android 4.x.x #240

Closed shm-original closed 4 years ago

shm-original commented 6 years ago

I use HTTPTileDataSource and RasterTileLayer for showing base layer from google TMS ,but in android 4.2.2 mapTiles couldnot be render and log this error in logcat.

I/carto-mobile-sdk: HTTPTileDataSource::loadTile: Loading http://mt0.google.com/vt/lyrs=r&x=33&y=32&z=6 E/carto-mobile-sdk: Bitmap::loadFromCompressedBytes: Unsupported image format E/carto-mobile-sdk: RasterTileLayer::FetchTask: Failed to decode tile

mtehver commented 6 years ago

Hi. Do you get this problem with only Android 4.2.2 or with other versions also? Quick tests on Android Emulator using Android 5.0 seemed to work ok.

Also, I think you are violating terms of Google by using their tiles without their SDK.

jaakla commented 6 years ago

To use google tiles in legal way you should use this API: https://developers.google.com/maps/documentation/tile/ . It is not free service, and not even part of usual paid plans, so you need to contact Google to enable it. In practise it works better if Google considers you as serious enterprise-level customer.

Technically you need to create map session in your app (SDK does not do this for you) and get session key, and then can configure raster tile layer with the created URL.

shm-original commented 6 years ago

Thank you for informing me about Google's rules, but I'm currently using Google's service for testing purpose only. Can the arised problem relate with this subject? I checked this problem on all versions of Android, but it seems that this problem only happens on Android 4.x.x.

mtehver commented 6 years ago

@shm-original I guess that HTTP transfer encoding handling is somewhat broken in Android 4.x.x (in the sense that Android itself does not properly inflate HTTP response message). SDK 4.4.1RC1 should have a workaround for that. Can you confirm it works now?

shm-original commented 6 years ago

@mtehver gradle show failed to resolve error when try to get sdk 4.4.1RC1. i think its not on Jcenter yet.

jaakla commented 6 years ago

How do you try to get it from the jcenter? This gradle conf should work:

implementation('com.carto:carto-mobile-sdk:4.1.4-rc.1@aar')
shm-original commented 6 years ago

I test the app on android 4.1.1 and 4.4.4, and its work perfectly. but loading tiles on android 4.2.2 still has the problem.

mtehver commented 6 years ago

@shm-original Can you make a small test app demonstrating the issue? The issue should be reproducible on Android Emulator with API level 17 (Android 4.2) for us to proceed. If this is a device specific issue (there are some really buggy devices in the wild), then I am afraid we can not help you, as we do not have any devices with 4.2.2 around.

shm-original commented 6 years ago

@mtehver I test the app on genymotion emulator "custom phone - 4.2.2", and i am not testing the app on physical device, as i do not have any devices with 4.2.2 around too.

mtehver commented 6 years ago

@shm-original Does the tile decoding issue happen only with raster tiles or does it happen also with CARTO basemap? If this is specific to Google raster tiles and Android 4.2.2 then I would probably mark this as 'wont fix' as Android 4.2.2 is really old by now and I the use case is somewhat obscure. Also, workarounds for such platform bugs may cause unwanted side effects. Googling 'Android 4.2' and 'HTTPURLConnection issues' results in several bug reports that seem to be fixed in later versions.

mtehver commented 4 years ago

Closing this due to inactivity. Also Android 4.x emulator issues are very low priority.