Formbricks Android SDK provides an easy way to embed Formbricks surveys and feedback forms in your Android applications via a WebView.
Add the Maven Central repository and the Formbricks SDK dependency to your application's build.gradle.kts
:
repositories {
google()
mavenCentral()
}
dependencies {
implementation("com.formbricks:android:1.0.0") // replace with latest version
}
Enable DataBinding in your app's module build.gradle.kts:
android {
buildFeatures {
dataBinding = true
}
}
// 1. Initialize the SDK
val config = FormbricksConfig.Builder(
"https://your-formbricks-server.com",
"YOUR_ENVIRONMENT_ID"
)
.setLoggingEnabled(true)
.setFragmentManager(supportFragmentManager)
.build()
// 2. Setup Formbricks
Formbricks.setup(this, config)
// 3. Identify the user
Formbricks.setUserId("user‑123")
// 4. Track events
Formbricks.track("button_pressed")
// 5. Set or add user attributes
Formbricks.setAttribute("[email protected]", "email")
Formbricks.setAttributes(mapOf(Pair("attr1", "val1"), Pair("attr2", "val2")))
// 6. Change language (no userId required):
Formbricks.setLanguage("de")
// 7. Log out:
Formbricks.logout()
We welcome issues and pull requests on our GitHub repository.
To run the instrumented tests, make sure you have an Android emulator running or a physical device connected, then execute:
./gradlew connectedDebugAndroidTest
The SDK uses JaCoCo for code coverage reporting. To generate a coverage report for instrumented tests:
- Make sure you have an Android emulator running or a physical device connected
- Run the provided script:
This will:
./generate-instrumented-coverage.sh
- Run the instrumented tests
- Generate a JaCoCo coverage report
- Open the HTML report in your default browser
Alternatively, you can run the Gradle task directly:
./gradlew jacocoAndroidTestReport
The coverage report will be generated at:
android/build/reports/jacoco/jacocoAndroidTestReport/html/index.html
This SDK is released under the MIT License.