Following guide provides general information for starting with Aerobase Services SDK.
To use a published version of the SDK you have to add jcenter to the build.grade file in your project’s root directory
allprojects {
repositories {
jcenter() // <-- Add This line
google()
}
}
In the build.gradle file of your app you can begin adding dependencies provided by the SDK.
dependencies { ... implementation 'org.aerobase:android-core:0.1.0-RELEASE' implementation 'org.aerobase:android-auth:0.1.0-RELEASE' // <- adjust to suit release version }
A full list of releases can be viewed here
Alternatively the SDK can be installed manually instead of using a published version.
git clone https://github.com/aerobase/aerobase-android-sdk
cd aerbase-android-sdk
./gradlew install
You can verify the install went well by checking your local maven repository
ls ~/.m2/repository/org/aerobase # Should output auth core
If you are using a build of the SDK from source you will need to add mavenLocal() to the build.gradle file in your project’s root directory.
allprojects {
repositories {
mavenLocal() // <-- Add This line
google()
jcenter()
}
}
In the build.gradle file of your app you can begin adding dependencies provided by the SDK.
dependencies { ... implementation 'org.aerobase:android-core:0.1.0-SNAPSHOT' implementation 'org.aerogear:android-auth:0.1.0-SNAPSHOT' //If you are using IDM services provided by KeyCloak }
In an example you can use the SDK as follows
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PushService pushService = MobileCore.getInstance().getService(PushService.class);
pushService.registerDevice(new Callback() {
@Override
public void onSuccess() {
MobileCore.getLogger().info("AB", "Successfully registered device to aerobase server");
}
@Override
public void onError(Throwable error) {
new AppExecutors().mainThread().execute(() -> {
MobileCore.getLogger().error("AB", error.getMessage(), error);
});
}
});
}
...
Our project provides a BOM artifact to lock the dependencies (direct and transitive) down to known compatible versions. Gradle itself does not offer such a mechanism but it is a well known and used concept in the Maven world (see Dependency Management ).
In order to bring this functionality to Gradle the Android SDK relies on the dependency management plugin provided by Spring. This plugin allows us to use a standard Maven BOM in a Gradle project.
-
Add gradle plugin to At the top of your gradle build file (but below
buildscripts
) add the plugin itself:
plugins { id "io.spring.dependency-management" version "1.0.4.RELEASE" }
-
Import bom plugin into your gradle config Add following code before your
dependencies
add thedependencyManagement
section that refers to our BOM:
dependencyManagement { imports { mavenBom 'org.jboss.aerogear:aerogear-android-sdk-bom:1.1.10' } }
-
In case your project contains multiple modules you need to apply this to all your subprojects. Make sure to apply the previous steps to your parent modules
build.gradle
and wrap thedependencyManagement
section as follows:
subprojects { apply plugin: 'io.spring.dependency-management' dependencyManagement { imports { mavenBom 'org.jboss.aerogear:aerogear-android-sdk-bom:1.1.10' } } }
-
After applying this changes developers can import the dependencies that are listed in the BOM without specifying a version:
dependencies { implementation group: 'org.aerobase', name: 'core' }
To implement certificate pinning in the individual SDKs, see the certificate pinning guide.