GlamAR is a powerful Augmented Reality SDK for Android that enables virtual try-on experiences for makeup, jewelry, and other beauty products. The SDK provides an easy-to-integrate solution with real-time AR capabilities, face detection, and product visualization features.
- Real-time virtual makeup try-on
- Multiple product category support
- Camera and image-based preview modes
- Real-time face tracking and analysis
- Easy integration with Android applications
- Snapshot functionality
- High-performance WebView-based rendering
- Original/Modified view comparison
- Configurable parameters
The GlamAR SDK is available on Maven Central. Add the following dependency to your app's build.gradle:
dependencies {
implementation 'io.pixelbin.glamar:glamar:2.0.6'
}Alternatively, you can manually include the .aar file:
- Place the
.aarfile in your project'slibsdirectory - Add the following to your app's
build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
}Sync your project with Gradle files.
Add these permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" /> <!-- Required for camera preview mode -->Initialize the SDK in your Application class to ensure it is set up when your app starts.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY")
}
}Don't forget to register your Application class in the AndroidManifest.xml:
<application
android:name=".MyApplication"
... >
<!-- Other configurations -->
</application>This "init" will prompt our SDK to create a webview and open our SDK in it.
To use the webview we have created you will need to add it your layout. Paste the following code inside your layout xml file where you want to show the webview.
<FrameLayout
android:id="@+id/glamARView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />Inside the activity class add the following code:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// This passes the activity context to the webview
GlamArWebViewManager.setUpActivityContext(this)
// This adds the webview created by SDK in the layout
GlamArWebViewManager.getPreparedWebView()?.let { webView ->
val glamARView = findViewById<FrameLayout>(R.id.glamARView)
glamARView.apply {
addView(webView)
}
}
}
}You should be able to see GlamAR SDK page being loaded.
Opens the SDK Home screen with relevant category module setup.
import io.pixelbin.glamar.model.GlamAROverrides
val overrides = GlamAROverrides(
category = "sunglasses",
)
GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY", overrides)
Open the SDK with Live mode (web camera) straightaway. This bypasses the SDK home screen.
import io.pixelbin.glamar.model.GlamAROverrides
import io.pixelbin.glamar.model.Configuration
import io.pixelbin.glamar.model.GlobalConfig
val overrides = GlamAROverrides(
category = "sunglasses",
configuration = Configuration(
global = GlobalConfig(
openLiveOnInit = true,
),
)
)
GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY", overrides)
Open SDK with disabled previous button and cross button.
import io.pixelbin.glamar.model.GlamAROverrides
import io.pixelbin.glamar.model.Configuration
import io.pixelbin.glamar.model.GlobalConfig
val overrides = GlamAROverrides(
category = "sunglasses",
configuration = Configuration(
global = GlobalConfig(
disableClose = true,
disableBack = false
),
)
)
GlamAr.init(context = this, accessKey = "YOUR_ACCESS_KEY", overrides)
Apply a SKU:
GlamAr.applySku(skuId = "SKU_ID")Take a snapshot of the current view:
GlamAr.snapshot()Ensure that you handle permissions appropriately, especially for camera access when using openLiveOnInit.
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
GlamArPermissionHandler.onRequestPermissionsResult(requestCode, grantResults)
}Event listeners are essential soon after initialization is called to start listening to GlamAR SDK callback events.
// Can be any event type sent from SDK
GlamAR.addEventListener("sku-applied"){
GlamArLogger.d("TAG", "sku-applied callback")
}Can also unregister from listening to events previously registered to but calling
GlamAR.removeEventListener("sku-applied")- Always handle permissions appropriately:
override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
GlamArPermissionHandler.onRequestPermissionsResult(requestCode, grantResults)
}- Initialize the SDK early in your application lifecycle
- Handle callbacks for better user experience
- Use appropriate preview modes based on your use case
- Implement proper error handling
- 1.0.2 (Latest)
- New updated GlamAR structure
- 1.0.1
- Maven Central release
- Enhanced face tracking
- Improved performance
- Bug fixes and stability improvements
For support and bug reports, please create an issue in our GitHub repository or contact our support team at support@pixelbin.io.
GlamAR SDK is available under the MIT license. See the LICENSE file for more info.