Abandon hope all ye who enter here

Published by Tobias Hofmann on

13 min read

Abandon hope all ye who enter here

“Gate of hell” – Inferno

I had to develop an app using SAP’s MDK. Per se that is not a problem at all. In fact, using BAS you can develop a mobile app fast without having to worry much about the details. What can make developing with MDK complicated is when you leave BAS: I had to use a custom branded client to run my MDK app. For this SAP provides an SDK. The idea is simple: the SDK serves as a starting point to bootstrap your own MDK client. The actual Android / iOS MDK client project is contained in the SDK. Via parameters the project can be adjusted (logo, namespace, onboarding, security, etc.).

The above graphic shows that most of the SDK tasks result in copying files, replace properties, and then use the native SDK for Android or iOS to compile the client. You do not load the MDK client project into your SDK (Android Studio / XCode). The MDK SDK is doing everything for you. The generated MDK client is the app you deploy on mobile devices. Later your branded MDK client is used to load the actual MDK app from mobile services and to run the app. If you ever had to build your own custom Fiori Mobile Client: it is the same procedure.

For this process to work, several tools used by the MDK SDK must be available in a certain version. That’s why SAP wants you to first do a pre-check of your developer setup to see if the MDK SDK will be able to build the custom client. That check is done by MDK Dependency Installer. After starting the dependency installer, it will automatically check the available setup. If all checks are passed you can start building your own MDK client app.

Passing all dependency checks can be harder than you might expect it to be. First, SAP is not going to provide an SDK where all dependencies are included. SAP does not include everything needed to compile the MDK client in the MDK SDK. Or allow to put all dependencies in a sub directory and just call the executables from a relative path. The developer needs to make the tools available. If you are not an Android / iOS developer, you need to make yourself familiar on how to developer native apps for Android / iOS. You need the SDK tools as you’d going to develop a native app. If you are a native Android / iOS developer, it is time to make yourself familiar with Node.js and NativeScript. Those tools are required dependencies and must be made available. And you must consider the versions SAP expects.

As SAP decided not to include these tools, nor to allow it to copy them into a relative folder inside the SDK, you must install them. Meaning: install them in a way you can use them. If you are already using Node.js or Native Script or Java or Android Studio, your configuration must match what SAP wants. Which normally will mean that you must invest some time to provide an environment that makes SAP happy while at the same time allows you to still use your coding tools.

Java

The MDK SDK needs Java for building the Android app. The Java version needed is JDK 1.8. This is checked by searching for javac and check the version string. This is not working as you might think: While JAVA_HOME is considered, javac is run from the location in the PATH variable. If your javac in PATH is different than the one given by JAVA_HOME, the check will fail.

Bild

The tool checks if JAVA_HOME is set. If not, it fails. Then it checks if javac has the correct version, using not the binary pointed to via JAVA_HOME, but using the binary found in PATH. Both the binary in PATH and JAVA_HOME must be the same!

Android

Installing the Android dependencies is not so easy, as Google by default only shows you the latest version available for installation. You must find the correct version and install that one.

ANDROID_HOME

Install Android Studio. It is needed for anything related to Android development. Set the ANDROID_HOME variable. The variable must point to the Android SDK.

“You can configure it by setting ANDROID_HOME=<Android SDK root folder path>.”

If you do not know where this is (and the Android Studio does a great job in hiding this from you, as you normally do not need to know the exact location for developing an Android app):

Open Android Studio

File -> Settings

Search for SDK

The SDK location is shown. This is the path you must use as value for ANDROID_HOME.

Android SDK, platform tools, build tools

Solving these dependencies is a little bit tricky. They can all be solved by installing the tools via the Android SDK Manager. The SDK Manager is showing by default the latest version of a component. To install the correct version, the view must be adjusted to also show older versions.

Open Android Studio

File -> Settings -> Search for SDK -> Android SDK

Alternative: click the SDK Manager icon in the Android Studio menu bar:

The dependency for the Android SDK, Platform-Tools, Tools and build tools are all solved via the Android SDK manager.

From there you can install the dependencies. To see older version of some required tools, check the “Show Package Details” option. This will show older versions of the components too and therefore make it easier to understand what needs to be installed to satisfy the MDK Dependency Installer.

Android SDK 30

Tab: SDK Platforms

Android SDK Platform-Tools

Tab: SDK Tools

There is only one option available, and the MDK dependency checker is graceful enough to accept anything >= 30.0.5

Android SDK Tools

The Android SDK tool page where you get directed to after clicking the link in the dependency checker tells you that this is deprecated. “This SDK Tools package is deprecated and no longer receiving update”. What SAP is looking for here is the cli package. You can download them, but when installing Android Studio, this dependency should be solved automatically.

Android SDK Build-Tools 30

Tab: SDK Tools

To install the required dependency (>=30.0.3 <= 30.0.99) the option “Show Package Details” must be checked. Select the correct one. In my case, only 30.0.3 fits the requirements.

Bild

Android Emulator

Tab: SDK Tools

Install the latest Emulator.

Node.js and Native Script

The MDK Dependency Installer provided the option to solve missing dependencies automatically. That’s great as here the tool gets out of the way and tries to make the live of the developer easier. Why it’s not possible to make this for all required dependencies? You can ask SAP that question, but either way, it won’t help as the “fix it” button is not fixing it. In my case, it failed to install Node.js and Native Script. To be honest, it tried and even reported success for Native Script. After restarting the dependency check, amnesia was all that was left.

Tool is trying to to install Native Script.

Bild

The output was promising: installed.

Bild

Restarting the dependency checker: not installed.

Bild

Therefore: nice try. As it is not working you’ll have to install the dependencies manually.

Node.js

This is real pain. Especially on a corporate IT controlled computer. Depending on what Node.js version is normally used to develop apps, it is necessary to install different version of Node.js. And to be able to switch between them easily. A Node.js version manager is needed. For Windows users it is recommended to use nvm-windows. Installing could be easy, but there is list of common issues you most probably will run into. Issues with nvm-windows can be solved having the correct permissions. If you do not have them, nvm won’t work.

Missing permissions:

Bild

Correct permissions:

Bild

Issue 1

One issue you might run into is with creating symlinks. For Windows 10 users, it is recommended to enable developer mode in Windows. This will allow nvm to create symlinks without asking you to provide admin credentials.

Bild

Install NVM Windows

Download NVM-Windows and run the installer as Admin.

Make sure you can write to the provided location. You should be able to create symlinks in <Path>\nodejs due to the developer mode activated earlier.

Issue 2

Next common issue is to use the wrong location for the node installations. Do not use C:\Program Files to install node to. Use a directory you have permission to use. Best is to use a directory in your %HOME%. For instance: %HOME%\dev\tools\nvm

Bild

Instruct nvm winows to use your custom location to manage node version.

nvm root <Path>\dev\tools\nvm

If you use now nvm to install a new version of node, or to switch to a already node version, the symlink will point to your own directory. As you have full permission there to create / delete files, nvm can be used to manage your node versions.

Install correct Node.js version

With nvm setup correctly, it is possible to install a Node.js version that the MDK Dependency Installer expects.

nvm install 12.21.0
nvm use 12.21.0

NativeScript

NativeScript is one of the easier dependencies to install. The project site contains the documentation on how to install NativeScript. It contains some information regarding Android SDK dependencies. If you are stuck at the Android installation, maybe the information there helps you. Installing NativeScript is easy. Ensure that Node.js and npm are working.

npm install -g nativescript

Summary

If all dependencies are installed the MDK dependency installer checks will pass. Now it is possible to start creating a custom MDK client.

As with the Divine Comedy, it might take a while to finish it, but now it is possible to create something amazing.

Let the world know

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.