Skip to main content

Flutter Troubleshooting

This document provides solutions to common issues encountered while using the GlamAR SDK in Flutter projects.

Common Issues and Solutions

1. Installation Problems

Issue: Errors during package installation.

Solution:

  • Ensure that your Flutter environment is correctly set up by following the Flutter setup guide.
  • Verify that all required packages (flutter_inappwebview, permission_handler) are added to your pubspec.yaml file and run flutter pub get to install them.

2. Camera Permission Denied

Issue: The SDK does not function because camera permission is denied.

Solution:

  • For Android, ensure that the following permissions are added to AndroidManifest.xml:
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera" android:required="true"/>
  • For iOS, add the following to Info.plist:
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera for showing virtual try-ons</string>
  • Ensure that the onPermissionRequest method is correctly implemented to handle permission requests.

3. WebView Not Loading

Issue: The InAppWebView does not load the SDK URL.

Solution:

  • Check the URL provided in initialUrlRequest and ensure it is correct.
  • Verify network connectivity and ensure that the device can access the internet.

4. SDK Initialization Fails

Issue: The SDK does not initialize properly.

Solution:

Ensure that the API key is correctly set in the initialization payload:

{
"type": "initialize",
"payload": {
"apiKey": "YOUR_ACCESS_KEY",
"platform": "flutter"
}
}
  • Replace 'YOUR_ACCESS_KEY' with the correct access key from your organization.

5. Event Listeners Not Working

Issue: Event listeners do not receive messages from the SDK.

Solution:

  • Ensure that the addJavaScriptHandler is correctly set up with the handler name onLog.
  • Verify that the JavaScript code in the listenGlaArEvent function is correctly implemented.

6. Additional Tips

  • Always test your application on both Android and iOS devices to ensure compatibility.
  • Keep your Flutter SDK and all dependencies up to date to avoid compatibility issues.

For further assistance, refer to the official documentation or contact support.