Configure an Android Studio project for mobile development with SAP HANA Cloud Platform Development and Operations
You will learn
You will modify an Android Studio project to include a number of resources from the SAP Mobile Platform SDK to provide secure login functionality (along with the accompanying UI components) as well as support for OData services. You must have already downloaded and installed the SAP Mobile Platform SDK and the latest patch release (if applicable) to continue.
After running the SDK installer you will find the native SDK files in the installation folder: <install_path>/MobileSDK3/NativeSDK/
To use the MAF Login Component you must import a number of Libraries and Resources. MAF Libraries were installed with the SMP SDK installer into the folder specified by you when you executed the installer. MAF is shipped with various resources including Android, iOS and Windows specific files like: images, layouts, localization, XML documents etc.
The procedure shown in this tutorial can be used for any of the Android activity types – including a “no activity” empty project. In this tutorial, we will use an application name, and UI activity titles that match the Android native app tutorial for the Northwind OData service.
Right click on app and select New > Module from the context menu.
Select Import .JAR/.AAR Package and click Next.
Click on the Browse button (...) and navigate to the SDK installation directory and find the mafsettingscreen-res-xxx resource folder. Click Finish.
The path should be: <install_path>/MobileSDK3/NativeSDK/MAFReuse/Android/libraries/mafsettingscreen-xxx.aar
Repeat steps 2-4 to import mafuicomponents-xxx.aar
The path should be: <install_path>/MobileSDK3/NativeSDK/MAFReuse/Android/libraries/mafuicomponents-xxx.aar
Repeat steps 2-4 to import maflogonui-xxx.aar
The path should be: <install_path>/MobileSDK3/NativeSDK/ODataFramework/Android/libraries/maflogonui-xxx.aar
Note maflogonui-xxx.aar is under the ODataFramework directory, not MAFReuse
Repeat steps 2-4 to import MobilePlace-xxx.aar. The MobilePlace.jar was replaced by the .aar package, so it needs to be included in the same way as the MAF packages.
The path should be: <install_path>/MobileSDK3/NativeSDK/ODataFramework/Android/libraries/MobilePlace-3.11.5.aar
Note MobilePlace-xxx.aar is under the ODataFramework directory, not MAFReuse
Your project should look like this now:
Right-click the the app module and select Open Module Settings then click on the Dependencies tab.
Click on the + icon to add a new dependency and select Module dependency.
Select them all and click OK and Android Studio will initiate a gradle build.
To import the remaining libraries, select the AfariaSLL.jar file in your SDK installation directory and right-click to copy the file.
The directory should be: <install_path>/MobileSDK3/NativeSDK/ODataFramework/Android/libraries/AfariaSLL-x.xxx.jar
In Android Studio in the Project and Project Files view, right-click on app and select paste. In the copy dialog box, add libs to then end of the To directory path and click OK. This will add the AfariaSLL library to the project as well as create the libs directory.
In your file system, copy the remaining libraries below from the <install_path>/MobileSDK3/NativeSDK/ODataFramework/Android/libraries/ directory, right-click on the new libs folder in Android Studio and select paste.
Using the Android Studio project view, copy the following jar libraries from the SDK installation folders and paste it into the libs folder in Android Studio.
odataoffline.jar (offline store)
ODataOnline.jar (online store)
In Android Studio, open the libs folder, select all the libraries you have added, right-click and select Add As Library….
In the Create Library dialog box, select the app module and click OK.
You can check the libraries were added in the build.gradle file located in the app module.