Search code examples
androidc++sdkpascalrad-studio

embarcadero rad studio android google maps app


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, but I can't get my new app to run.

I am using 32-bit Android with an LG Q7+ phone and RAD Studio 10.3.3

This also is happening with the sample Map Type Selector both C++ and Pascal versions so I think it must have something to do with FMX.Maps.Android.

I tried it with my first working project as well, but as soon as I added the TMapView control with proper settings and built it, it just crashes the same way with the null error on line 1525 in FMX.Maps.Android.pas file. This is definitely not my code :)

Most minimal sample I guess would be to create a c++ project with a TMapView control and fill in the required settings and run or just run the Map Type Selector sample with an Android 32-bit device.

I added all proper uses permissions for the app, added the google mapping service entitlement, added my special API key as well just like all the articles I have come across say to do for the app to run but I just get a crash:

"Project map_cpp.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'. 

Screenshot: https://i.sstatic.net/xxn00.png crash

I've linked to the proper SDKs from what I can tell. Even tried multiple java SDK versions with no luck, same crash. I can't see anything wrong by the callstack but I am definitely not a java or pascal programmer by any means either and fairly new to RAD Studio.

Looking at the android monitor, the only thing that sticks out to me and looks like a possible authentication error is:

"unable to connect to service com.google.android.gms.auth.key.retrieval.service.start" 

but I can't be for certain and like I said before, I followed the online setup guides. I am linking to the setup articles I followed below:

http://docwiki.embarcadero.com/RADStudio/Rio/en/Mobile_Tutorial:_Using_a_Map_Component_to_Work_with_Maps_(iOS_and_Android)

http://docwiki.embarcadero.com/RADStudio/Rio/en/Configuring_Android_Applications_to_Use_Google_Maps

Android Monitor Log:

03-28 09:45:57.559: I/rcadero.map_cp(28426): The ClassLoaderContext is a special shared library.
03-28 09:45:57.681: D/PhoneWindow(28426): windowLightStatusBar : false, disable View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
03-28 09:45:57.815: I/C:\src\rtl\source\startup\startup_android.cpp(28426): ###################### Calling __initialize_pascal_units
03-28 09:45:57.815: I/C:\src\rtl\source\startup\startup_android.cpp(28426): ### __initialize_pascal_units: start
03-28 09:45:57.815: I/C:\src\rtl\source\startup\startup_android.cpp(28426): ### _embtinit_start: 0x0x89491450  _embtinit_end: 0x0x89494884
03-28 09:45:58.345: I/C:\src\rtl\source\startup\startup_android.cpp(28426): ### __initialize_pascal_units: finished
03-28 09:45:58.431: D/OpenGLRenderer(28426): Skia GL Pipeline
03-28 09:45:58.701: I/Adreno(28426): QUALCOMM build                   : f161b04, I0380b38922
03-28 09:45:58.701: I/Adreno(28426): Build Date                       : 04/06/19
03-28 09:45:58.701: I/Adreno(28426): OpenGL ES Shader Compiler Version: EV031.25.03.03
03-28 09:45:58.701: I/Adreno(28426): Local Branch                     : mybranche9580cbd-6698-f10a-bcc9-1458d0b52ae8
03-28 09:45:58.701: I/Adreno(28426): Remote Branch                    : quic/gfx-adreno.lnx.1.0.r52-rel
03-28 09:45:58.701: I/Adreno(28426): Remote Branch                    : NONE
03-28 09:45:58.701: I/Adreno(28426): Reconstruct Branch               : NOTHING
03-28 09:45:58.701: I/Adreno(28426): Build Config                     : S L 6.0.7 AArch32
03-28 09:45:58.705: I/Adreno(28426): PFP: 0x005ff110, ME: 0x005ff066
03-28 09:45:58.712: I/ConfigStore(28426): android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
03-28 09:45:58.713: I/ConfigStore(28426): android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
03-28 09:45:58.762: W/System.err(28426): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.ClassLoader java.lang.Class.getClassLoader()' on a null object reference
03-28 09:45:58.762: W/System.err(28426):    at com.embarcadero.rtl.ProxyInterface.CreateProxyClass(ProxyInterface.java:16)
03-28 09:45:58.762: W/System.err(28426):    at android.app.NativeActivity.onStartNative(Native Method)
03-28 09:45:58.763: W/System.err(28426):    at android.app.NativeActivity.onStart(NativeActivity.java:223)
03-28 09:45:58.763: W/System.err(28426):    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1392)
03-28 09:45:58.763: W/System.err(28426):    at android.app.Activity.performStart(Activity.java:7180)
03-28 09:45:58.763: W/System.err(28426):    at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3045)
03-28 09:45:58.764: W/System.err(28426):    at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
03-28 09:45:58.764: W/System.err(28426):    at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
03-28 09:45:58.764: W/System.err(28426):    at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
03-28 09:45:58.764: W/System.err(28426):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
03-28 09:45:58.765: W/System.err(28426):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864)
03-28 09:45:58.765: W/System.err(28426):    at android.os.Handler.dispatchMessage(Handler.java:106)
03-28 09:45:58.765: W/System.err(28426):    at android.os.Looper.loop(Looper.java:205)
03-28 09:45:58.765: W/System.err(28426):    at android.app.ActivityThread.main(ActivityThread.java:6991)
03-28 09:45:58.765: W/System.err(28426):    at java.lang.reflect.Method.invoke(Native Method)
03-28 09:45:58.766: W/System.err(28426):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
03-28 09:45:58.766: W/System.err(28426):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)

Thanks for any help!


Solution

  • Dave Nottage figured it out - link below:

    "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."

    https://www.delphiworlds.com/2019/02/a-fix-for-using-tmapview-on-android-9-devices/#comment-9841