Android
Introduction
The SDK supports programmatic integration with Kotlin or Java.
These instructions assume that you have already read the Developer Guide. If you have not yet done so, please do so before continuing below.
This SDK comes with examples: a full Android Studio project is enclosed, written in Java. You can play with this example to understand how SDK integration works.
Installation
Unpack the ReblazeSDK.zip to your computer, and add the dependency:
In the project build.gradle:
… and then in the module build.gradle, add the SDK:
After you click Sync Project with Gradle files, the library will be available, and Android Studio will insert the import statement in your source files that need it:
About ReLinker support
For historical reasons, the example includes dependency on ReLinker.
If your app also uses ReLinker, then Reblaze SDK can make use of it. The proguard.txt
that is shipped in the SDK bundle, includes this rule to keep ReLinker classes and methods, to make sure to add keep rules so that ReLinker code is not stripped from the final app or dex file.
Finding the App Signature
For an Android app, you can get the SHA-256 fingerprint from the keystore or extract it from a signed APK:
apksigner is a utility supplied with Android SDK, it can typically be found in $ANDROID_SDK/build-tools/$BUILD_TOOLS_VERSION
directory.
See detailed instructions here.
When uploading the fingerprint to the Reblaze Console, make sure that it contains hexadecimal characters only, in lowercase, without spaces.
During testing, you may allow running the app on an Emulator. This will use a special signature: "abadbabe"
. Make sure that this is disabled on Production. Note that you can also use Offline Testing both on Emulator and on a physical device.
There is a protocol between the SDK and the backend that negotiates the signature remotely and notifies the system of a new one, if such was generated. The communication between the components takes place under the /74d8-ffc3-0f63-4b3c-c5c9-5699-6d5b-3a1f endpoint, and when a new signature is introduced, it will be provided as a value for the header named "sig" (see screenshot below). This new signature shall then be added to the app signatures list under the Mobile SDK settings in Reblaze Console. To find it easily in the View Log, use this filter:
url:/74d8-ffc3-0f63-4b3c-c5c9-5699-6d5b-3a1f
Initialization and Configuration
We recommend using no-code configuration. You need to supply a resource string ReblazeURL in your application resources, e.g. by dropping the following file into the res/values directory of your Android Studio project:
All other parameters will be received though Remote Configuration.
If you prefer to configure the SDK programmatically, it's best to override the Application's onCreate()
On Android, the userAgent property is a shortcut for System.getProperty("http.agent")
Auto-signing WebView Requests
You can use loadRequest
or loadUrl
to load a page that will be securely signed by Mobile SDK. But this will not extend signatures for the links embedded in the page, or AJAX requests and other resources. To include these, your WebView should use the WebViewClient class from the com.reblaze.sdk package.
The snippet above shows that com.reblaze.sdk.WebViewClient extends the Android WebViewClient and can be further extended if necessary. All HTTPS requests for such webView that go to your backendUrl will be automatically signed by the SDK.
Last updated