cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Map Extension does not recognize androidContext() in MDK application

Former Member
0 Likes
1,135

Hi guys,

currently I develop an MDK application in Visual Studio Code using your MDK extension for VSC.

I added the extension you created from: https://developers.sap.com/tutorials/cp-mobile-dev-kit-map-extension.html. Note, that I didn't change any code, its the same version posted in the tutorial.

For iOS, the map works as expected, but for Android, I recognized some issue. I checked for your documentation (https://help.sap.com/viewer/977416d43cd74bdc958289038749100e/3.2/en-US/9411d35cb91a4a8986a2635b7375c...) and analogue to it, the Map extension tries to create a new instance for the "_mapView" variable (object of class MapView):

this._mapView = new com.google.android.gms.maps.MapView(this.androidContext());

This line, however, throws a java.lang.NullPointerException, because the context of android (this.androidContext()) is null for me.

In the second link I posted above, the following information is delivered about the androidContext:
androidContext() - this function returns the current page's context that will be needed to create an Android native view.

Do you have any idea, why this problem occurs? Do I maybe have to adjust something, since, e.g., the mdk client sdk has been changed? In my TypeScript-file, the current android context is null and that is why I think, that the NullPointerException is thrown.

Thank you in advance for your help!

Best regards,

Sher-Chan Kodirov

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

hi jitendrakumar.kansal,

for your info, I found the solution. After I exchanged the "this.androidContext()" with app.android.context in the code of your tutorial (for the map extension), I was finally able to display the correct result.

BR,

Sher-Chan Kodirov

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Likes
Sher-Chan KodirovThanks for heads-up. Glad you got it working.coming to original query, i see it working with source code mentioned in the tutorial and also debugging the "this.androidContext()" returns below.You can raise an OSS ticket for further investigation if something breaks as per tutorial.
Object {constructor: , _needRestart: false, _callbacks: ActivityCallbacksImplementation}
_callbacks:ActivityCallbacksImplementation {_rootView: Frame}
_needRestart:false
constructor:function () { … }
isNativeScriptActivity:true
skipExit:undefined
super:Object
__proto__:Activity {constructor: } 

Answers (1)

Answers (1)

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert

sherchan_kodirov19

I quickly tested same tutorial on Android client built using MDK SDK 4.2.1 and can see the expected result.

Which MDK SDK version you are trying with?

Did you already follow step#8 to add required info in grandle & AndroidManifest.xml files?

Regards

JK

Former Member
0 Likes

hi jitendrakumar.kansal,

by the way, I am using a macOS Catalina with Version 10.15.4 and I have the MDK SDK version "MDKCLNT02P_1-80005072". I setup my whole dev environment for both iOS & Android.

And yes, i followed step#8 setting gradle-file as well as AndroidManifest.xml file in the built application I use for debug app root.

BR,

Sher-Chan Kodirov

Jitendra_Kansal
Product and Topic Expert
Product and Topic Expert
0 Likes

You can find MDK SDK version in Readme.html file under SDK folder. By looking at folder name, looks like it's 4.2.1

In order to further investigate this issue, could you raise an OSS ticket (component MOB-MDK) , attach your local.mdkproject, metadaproject

Former Member
0 Likes

hi jitendrakumar.kansal,

it's the version 4.2.1 for my MDK Client SDK. However, sure, I can share my code so you can get any idea!

BR,

Sher-Chan Kodirov

Former Member
0 Likes

hi jitendrakumar.kansal ,

my colleague has a Windows device and he told me, that for him, the this.androidContext() was null, too.

However, in another extension, he created a new instance of an EditText (Android) https://developer.android.com/reference/android/widget/EditText.html

The textfield rendered for him, but in his Android debugger, "this.androidContext()" is also null.

Is it normal, that the debugger shows no data for that?

BR,

Sher-Chan Kodirov