Skip to Content
Author's profile photo Pavan Kowshik Santebidanur Nagaraja

Mobi Android SDK setup using Android Studio

In this blog we will understand how to set up the Mobi Android SDK project with Android studio.  We will also understand the changes to be made to create new product flavors of the SDK project which in simple words mean we create an application which can be installed along side the Mobi application published by SAP on google Play store.

 

The blog is divided into four major parts:

*Installation of Android Studio

*Configuring the SDK project in Android Studio

*Modifying the project to enable “Side by Side” installation along with Mobi application present on Android Play Store( Supported from Mobi Android SDK version 6.1.7)

*Signing the release build

Installation of Android Studio

Android Studio is now the official Android IDE. For “side by side” installation of the play store app and the SDK app the gradle build system present in Android studio is required. Eclipse does not support this feature.

Download Android Studio from the link http://developer.android.com/sdk/index.html

Start installation by double clicking the downloaded Android studio Installer.
Click on ‘Yes’ if you are prompted with a security warning

/wp-content/uploads/2015/02/warning_642178.png

Click on Next to Continue the installation

Next_1.png

Select all the components for installation

/wp-content/uploads/2015/02/selectall_642303.png

Select the location for all the components to be installed. ( Default recommended)

/wp-content/uploads/2015/02/location_642304.png

Click on “Next” and “Install” in the subsequent Windows to proceed with the installation!

Now select the “SDK Manager” option from the tool bar to install the following Components

Untitled.png

Once the Installation is done Close SDK Manager and also Android Studio!

 

Configuring the SDK project in Android Studio

Download the zip file SAPBusinessObjectsMobileAndroidLib-X.X.X.zip

Extract it to the folder SAPBusinessObjectsMobileAndroidLib-X.X.X

(Note: The zip file name may vary from the actual file which you download from SMP and hence the name of the extracted folder name will also not be the same. The name used here serves as a placeholder)

Run android studio and you should be greeted with a welcome menu as given below. Select the Open an existing Android Studio project option as highlighted.

 

Go to the location where the unzipped folder exists and select the root level folder as shown below and Choose OK

In the next screen, choose OK as highlighted

 In the next screen,choose Don’t remind me again for this project as highlighted

 

 

Now select File->Settings->Instant Run(under Build, Execution, Deployment), uncheck  the highlighted item and choose OK

 

 

The project is all set! You can run the application by clicking on theplay button.png button in the tool Bar

 

 

Modifying the project to enable “Side by Side” installation along with Mobi application present on Android Play Store

 

 

Open the build.gradle file under app (as done before)
Add the following lines and then click on “Sync now” like before.

 

    productFlavors{

          <Your-Flavor-Name>{

              applicationId <Unique-Application-id>

          }     

    }

Example-

    productFlavors{

          sdk{
applicationId “com.sdk.mobi”

          }

    }   

 

(Note- Please make sure your applicationId is not com.sap.mobi )

 

/wp-content/uploads/2015/02/productflavours_642365.png

 

Now open the AndroidManifest.xml (Under Android->app->manifests)

/wp-content/uploads/2015/02/manifest_path_642366.png

Change the android authority attribute under both the provider tags! This value should be the same as the applicationId given in the previous step.

/wp-content/uploads/2015/02/authority_642367.png

Open the file defaultSettings.xml and change the value under the feature.package.name.default tag to the applicationId given in the previous steps.

/wp-content/uploads/2015/02/defaultsettings_642368.png

Now select Build->Rebuild Project.

The project is all set! You can run the application by clicking play button.png on the button in the tool Bar.

 

 

Creating Multiple Applications

You can create more than one application by having multiple product flavors. You can select different build variants from build variants tab.

An important step after this is to make sure you change the values in AndroidManifest.xml and defaultSettings.xml with the application id of the variant chosen currently. ( As shown in the previous section)

 

/wp-content/uploads/2015/02/multiple_productflav_642370.png

 

/wp-content/uploads/2015/02/build_variant_642371.png

 

 

Signing the release build

 

Select the ‘release’ build variant under the build variants tab and then Sign your application!

Release.png

Sign your application following the guidelines given by google. http://developer.android.com/tools/publishing/app-signing.html

Align the APK after signing http://developer.android.com/tools/help/zipalign.html

Publish your APK onto the play store by signing up on Google Play Developer Console.

 

 

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      This is very helpful....

      Author's profile photo Manuel Ramirez
      Manuel Ramirez

      Hi Pavan.

      We are following your guide and it works ok for Android 5.x.x, but not in 4.4.x, do you know if there is any limitation with this version?

      Regards.

      Author's profile photo Pavan Kowshik Santebidanur Nagaraja
      Pavan Kowshik Santebidanur Nagaraja
      Blog Post Author

      It should ideally work for all devices! Can you please let us know your android studio version? Will help us understand what the problem is and possibly update the blog with a solution.

      Author's profile photo Pavan Kowshik Santebidanur Nagaraja
      Pavan Kowshik Santebidanur Nagaraja
      Blog Post Author

      Hello Ramirez,

      I have updated the blog to address the issue you are facing. I have attached a gradle file which works for us on different versions of android studio. Can you please try out the same versions of different components in the gradle file and let us know if it works for you. I verified that the attached gradle file works on Android Studio 1.5  with a kit kat device( Samsung Note 3)

      Regards,

      Pavan

      Author's profile photo Tinyiko Chauke
      Tinyiko Chauke

      Hi Guys

      The articles seem very helpful however am having an error after doing the following:

      1 . i added a flavor as below:

      transtnetBi{
          applicationId "com.transtnetBi.net"
      
      }

       

      Then i sync the project and got this error:

      Could not find common.jar (android.arch.core:common:1.0.0).
      Searched in the following locations:
      https://jcenter.bintray.com/android/arch/core/common/1.0.0/common-1.0.0.jar

       

      This is how the dependencies looks like :

      dependencies {
          compile files('libs/sap-e2etrace-2.3.9.0.jar')
          compile files('libs/ClientLog-3.14.0.jar')
          compile files('libs/Common-3.14.0.jar')
          compile files('libs/Connectivity-3.14.0.jar')
          compile files('libs/AfariaSLL-7.00.6169.0.jar')
          compile files('libs/perflib-1.2.0.jar')
          compile files('libs/SupportabilityFacade-3.14.0.jar')
          compile files('libs/DataVaultLib-3.14.0-sap-04.jar')
          compile 'com.google.android.gms:play-services:6.5.87'
          compile 'com.android.support:support-v4:26.1.0'
          compile(name:'CoreServices-3.14.16',ext:'aar')
          compile(name:'android-database-sqlcipher-3.5.4',ext:'aar')
          compile(name:'Request-3.14.0',ext:'aar')
          compile files('libs/SAPBusinessObjectsMobileAndroidLibrary.jar')
      
      }

       

      Please help, how do i  fix this error.