A recent report on Embarcadero’s Quality Portal caught my attention today, where an app would crash if it used a TMapView on an Android 9 device. Fortunately, I had just recently updated my Nexus 5X to Android 9 (thanks to Brian Long’s help), so I could investigate the problem.
First thing to do was to create a new project, place a TMapView on the form, populate the apiKey value in the project options:
..and check the Maps Service checkbox in the Entitlements section:
Next, I fired up Monitor, which comes with the Android SDK tools (run monitor.bat, which is in the tools folder from the root of the Android SDK) and start the Android app. Lo and behold, when the app crashed, the logcat messages indicated an error:
A quick Google of the error (searching on “Failed resolution of: Lorg/apache/http/ProtocolVersion”) revealed a discussion on StackOverflow, and more importantly, what to do about it. The solution is incredibly simple: just add a tag to the AndroidManifest.template.xml:
the text is:
<uses-library android:name="org.apache.http.legacy" android:required="false" />
..and all is good in the world again!
Thanks a lot for helping me, Dave! You made my day! I’m an author of that damn RSP-23638 π
Maybe you could watch (and fix) another problem too: TMapView + Android 5? (It’s RSP-23379) π
You’re welcome! Regarding RSP-23379, can you use the same process as I did for the problem? i.e. Use Monitor to view logcat messages when the app starts. I’m assuming that “all I see is a black screen with logo on boot” means that the app is running, but does not display anything at all? Please post your replies in the comments on the actual report – I’ll be watching it π
Thanks again, Dave! π
It works with Android 9.0 but unfortunately it doesn’t work with Android 5.0 :-/
Log from monitor.bat: https://pastebin.com/NwbhJTvE
@NK, please post that log to the QP report as Dave requested, along with any additional comments that will assist anyone looking at the bug
However the key line appears to state you need to update some software on your device:
“Google Play services out of date. Requires 7095000 but found 6188734”
This sort of message is covered elsewhere, including this Android book where the explanation is that the device software (Google Play Servoices) is out of date and not current enough: https://books.google.co.uk/books?id=HVQ-CwAAQBAJ&pg=PA247&lpg=PA247&dq=Requires+7095000
Please attend to this and re-test and report back.
Sorry I can’t update anything – I make it for all (not for my device only). I can’t say to my clients “update your device or buy something new” you know. What if their mobiles/tablets with Android 5.0 are “unupdatable” or they are could not to update them? BTW Google still support Android 5.0 so I need a common workaround for Android 5.0 as is without any firmware’ updates.
I’m not entirely sure you understand what’s being suggested here. I’m not saying update the installed Android version. I’m talking about a software component. Something that is installed in the stock ROM, but has updates available in the Play Store. This is a common thing that is required. An app may validly require a later version of some system service, where updates are available through the Play Store.
My bad! I created and logged in to my test account (device was absolutely untouchable before – i.e. without any active Google user) and update a Google Play Service. And after that I got a true miracle π
But I was sure that I don’t need any active account :-/
Well I’ll try to close my RSP-23379.
Thanks again! All my questions about TMapView are closed – now TMapView works fine on Android 5/6/7/8/9. Waiting for Android 10 π
Excellent news! Thank you for the reply.
Hello Dave,
Sorry for reopening this… but I just recently have a problem with TMapView, but not the same as above. Can you please take a look into the log, and possibly see something I don’t see? I am not such an “android expert”.
Thanks in advance!
09-07 12:07:43.542: D/SurfaceView(24310): onWindowVisibilityChanged(0) true com.embarcadero.firemonkey.form.FormView{ac0b9f7 VFE…… ……I. 0,0-0,0} of ViewRootImpl@47c2ab3[FMXNativeActivity]
09-07 12:07:43.582: W/System.err(24310): java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.ClassLoader java.lang.Class.getClassLoader()’ on a null object reference
09-07 12:07:43.583: W/System.err(24310): at com.embarcadero.rtl.ProxyInterface.CreateProxyClass(ProxyInterface.java:16)
09-07 12:07:43.584: W/System.err(24310): at com.embarcadero.rtl.ProxyInterface.dispatchToNative(Native Method)
09-07 12:07:43.584: W/System.err(24310): at com.embarcadero.rtl.ProxyInterface.invoke(ProxyInterface.java:21)
09-07 12:07:43.585: W/System.err(24310): at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
09-07 12:07:43.585: W/System.err(24310): at $Proxy7.onTouchEvent(Unknown Source)
09-07 12:07:43.585: W/System.err(24310): at com.embarcadero.firemonkey.form.FormView.onTouchEvent(FormView.java:39)
Hi Davor,
There’s nothing in the log that gives me a definite clue. Do you have a test project that reproduces the problem?
Hi Dave. Just a wild shot because I came across your post while trying to figure out my error. I am new to Android programming but I get the gist of it. I come from a c++ background. I made a simple google map app that call a maps url from a webbrowser control and that worked well but now I am trying to add more functionality in a second app by using a TMapView control, and I can’t get my new app to run. I just get a crash “Project LocationDemoProject.apk raised exception class EJNIException with message ‘java.lang.NullPointerException: Attempt to invoke virtual method ‘java.lang.ClassLoader java.lang.Class.getClassLoader()’ on a null object reference’. I’ve linked to the proper SDKs from what I can tell. Even tried multiple versions with no luck, same crash. I can’t see anything wrong by the callstack but I am definitely not a java programmer by any means either. Thanks for any help.
Hi Andrew,
Are you using Delphi for this, or C++ Builder? If Delphi, do you have an example project, or steps?
Hi Dave, C++ builder I believe because it is in the rad studio samples CPP folder at “CPP\Multi-Device Samples\Device Sensors and Services\Map Type Selector”.
I come from a C++ background and would love to get this to work! I believe it is actually the same issue as Davor hit above. I outlined everything at https://stackoverflow.com/questions/60825272/embarcadero-rad-studio-android-google-maps-app
if you would be so kind to take a look. I just can’t find anything related to why it is crashing.
Hey Dave! I decided to try the Pascal sample and it crashes in the same exact way. I am really leaning towards an issue with FMX.Maps.Android so I am going to see about possibly finding other versions. This is all really new to me but other samples build and run just fine.
Some sample apps need updating to use the new Google Play Services libraries. To do this, in Project Manager under Target Platforms, expand the target Android platform, right-click Libraries and click “Revert System files to default”. Rebuild the app and it should be OK.
You rock Dave! That was the problem! Thank you a ton!
Just tested these ideas with RIO 10.3.3 — Had to do the revert to standard libraries. Still had crashes after one complicated screen opened. I added the additional manifest line and it seems to work. I will explore more.
Android 10, 64 bit, Android S10E phone.
Map now displays.
Will test 32 bit tablets later.
Thanks.
Dave