X

The Mobile & Digital Assistant Blog covers the latest in mobile and conversational AI development and engagement

A quick checklist for setting up your Android Studio application for Oracle Mobile Cloud Service

Chris Muir
Product Manager

A few months back I wrote a post entitled A quick checklist for setting up your iOS application for Oracle Mobile Cloud Service. The goal being if you're familiar with the steps but you just need a quick reminder, you can use the checklist to ensure you've done everything you need too.

Yesterday somebody asked me for the Android Studio equivalent.  So here we go, a quick list of steps to load the Android MCS SDK into an existing Android Studio application.

Don't forget this is covered in more detail in our YouTube videos, and the Using Oracle Mobile Cloud Service documentation includes detailed instructions too.

 

  1. Download the Android SDK from MCS and unzip it.
  2. With your favourite file manager copy all the JAR's in the extracted SDK zip directory to your Android Studio project app/lib directory.
  3. Also within the SDK directory extract the IDMMobileSDK zip file.
  4. Returning to Android Studio select File -> New -> New Import, then in the dialog select the IDMMobileSDK subdirectory under the SDK directory you just extracted.  Ensure the Module Name starts with a capital letter I to avoid a bug in some earlier versions of Android Studio.
  5. Still in Android Studio, open the application's build.gradle file and add the following dependencies if not already present:

compile fileTree(dir: 'libs', include: ['*.jar'])

compile project(':IDMMobileSDK')
  1. With your file manager copy oracle_mobile_cloud_config.xml to your app's app/src/main/assets directory.  If the assets directory doesn't exist create it first.
  2. In Android Studio update the oracle_mobile_cloud_config.xml settings and substitute the required values from the MCS MobileBackend.  An example file can be seen below.
  3. Still in Android Studio update the AndroidManifest.xml file to include the following permissions:

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  1. In Android Studio sync the project with the gradle file. If no errors are raised you are done.

An example oracle_mobile_cloud_config.xml file:


<?xml version="1.0" encoding="utf-8" ?>

<mobileBackends>

    <mobileBackend>

        <mbeName>ExampleMBE</mbeName>

        <mbeVersion>1.0</mbeVersion>

        <default>true</default>

        <appKey>66d9e504-1265-4bb9-b354-4565cf64552</appKey>

        <baseUrl>https://examplebaseurl:443</baseUrl>

        <enableAnalytics>true</enableAnalytics>

        <enableLogger>true</enableLogger>

        <authorization>

            <offlineAuthenticationEnabled>true</offlineAuthenticationEnabled>

            <authenticationType>basic</authenticationType>

            <basic>

                <mobileBackendID>c22ddd8b-3a6d-4444-5654-e42a0ffe4011</mobileBackendID>

                <anonymousKey>UFJJTUVfREVDRVBUSUNPTl9NT0JJTEVfQU5PTllNT1VTX0FQUElEOnZrZWJxUmwuamEwbTdu</anonymousKey>

            </basic>

            <oauth>

                <oAuthTokenEndPoint>https://exampleouthurl/oam/oauth2/tokens</oAuthTokenEndPoint>

                <oAuthClientId>12bf1234-23567-4f8b-1c35-d6c76434eb5a</oAuthClientId>

                <oAuthClientSecret>TLZhkAaaKisdbbbQfdL7</oAuthClientSecret>

            </oauth>

        </authorization>

    </mobileBackend>

</mobileBackends>

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.

Recent Content