OMH is an Android SDK, available as open-source, that simplifies the process of swapping services such as Maps & Location, Sign-in, Storage, and more, for both Android GMS and Non-GMS devices.
It aims at creating low coupled, extensible SDK reducing the code boilerplate of switching between GMS, Non-GMS, or any other service, and also provides a custom full open source alternative services switching automatically according to your configuration in the Gradle plugin giving the right outputs without overloading your APK with unnecessary libraries.
The OMH Core is a Gradle plugin that allows developers to configure, enable and set-up the OMH SDK in their projects.This plugin automatically implements the necessary dependencies and enable the custom-build variants to allow you compile the different builds to use the defined providers.
Go to your app build.gradle file and add the following:
plugins {
...
id 'omh-core'
}
...
omhConfig {
bundle('worldwide') {
it.auth {
addGmsService 'com.omh.android:auth-api-gms:1.0-SNAPSHOT'
addNonGmsService 'com.omh.android:auth-api-non-gms:1.0-SNAPSHOT'
}
}
bundle('gmsStore') {
it.auth {
addGmsService 'com.omh.android:auth-api-gms:1.0-SNAPSHOT'
}
}
bundle('nonGmsStore') {
it.auth {
addNonGmsService 'com.omh.android:auth-api-non-gms:1.0-SNAPSHOT'
}
}
}
You can also see this video:
plugin_installation.mp4
private val omhAuthProvider = OmhAuthProvider.Builder()
.addGmsPath(BuildConfig.AUTH_GMS_PATH)
.addNonGmsPath(BuildConfig.AUTH_NON_GMS_PATH)
.build()
private val omhAuthClient = omhAuthProvider.provideAuthClient(
scopes = listOf("openid", "email", "profile"),
clientId = "YOUR_CLIENT_ID",
context = applicationContext
)
In you sample app, perform the authentication
private fun startLogin() {
val loginIntent = omhAuthClient.getLoginIntent()
loginLauncher.launch(loginIntent)
}
If the authentication is successful, then navigate to your desired screen
private val loginLauncher: ActivityResultLauncher<Intent> =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
try {
omhAuthClient.getAccountFromIntent(result.data)
navigateToLogIn()
} catch (exception: OmhAuthException) {
val errorMessage = OmhAuthStatusCodes.getStatusCodeString(404)
}
}
You can also see the video:
plugin_usage.mp4
See example and check the full documentation at our Wiki.
We'd be glad if you decide to contribute to this project.
All pull requests are welcome, just make sure that every work is linked to an issue on this repository so everyone can track it.
- Add this code
packagingOptions {
exclude("META-INF/DEPENDENCIES")
}