https://github.com/blundell/aicoreminsdktemplate
AICore has minSDK 31, this template shows how to use it in a lower minSDK Android app
https://github.com/blundell/aicoreminsdktemplate
ai androiddev gemini-api mediapipe
Last synced: 6 months ago
JSON representation
AICore has minSDK 31, this template shows how to use it in a lower minSDK Android app
- Host: GitHub
- URL: https://github.com/blundell/aicoreminsdktemplate
- Owner: blundell
- Created: 2025-03-10T21:33:38.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-10T21:43:15.000Z (10 months ago)
- Last Synced: 2025-06-26T01:08:41.537Z (7 months ago)
- Topics: ai, androiddev, gemini-api, mediapipe
- Language: Kotlin
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#### AICore has minSDK 31, this template shows how to use it in a lower minSDK Android app
- The app module is minSDK 29
- The gemini module is minSDK 31
Normally you would get a manifest merger error:
```
Manifest merger failed : uses-sdk:minSdkVersion 29 cannot be smaller than version 31 declared in library [:gemini] /MyApplication/gemini/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml as the library might be using APIs not available in 29
Suggestion: use a compatible library with a minSdk of at most 29,
or increase this project's minSdk version to at least 31,
or use tools:overrideLibrary="com.blundell.tut.gemini" to force usage (may lead to runtime failures)
```
This example uses `tools:overrideLibrary` in combination with a SDK version check in the gemini module, to allow you to test out AICore in
an application that has a lower minSDK that Gemini AICore requires.
- Inside of `gemini/src/main/java/com/blundell/tut/gemini/SecondViewModel.kt` there is an SDK atLeast check.
- The `:gemini` module navigational composable checks with the ViewModel before proceeding to the UI.
- `androidx.navigation.compose.NavHost` is used in the `MainActivity` to navigate between the two modules composables.
We will either show the `SecondScreen` or show a `NoAccessScreen`:
```kotlin
@Composable
fun SecondComposable(viewModel: SecondViewModel = viewModel()) {
val accessible = remember { viewModel.onRequestAccess() }
if (accessible) {
val state by viewModel.state.collectAsState()
SecondScreen(state) {
viewModel.onSubmit(it)
}
} else {
NoAccessScreen()
}
}
```