Open
Description
Checklist
- I have read the contributing guidelines
- I have determined whether this bug is also reproducible in a vanilla Android project
- If possible, I've reproduced the issue using the
master
branch or latest release of this package. - This issue hasn't been addressed in an existing GitHub issue or pull request.
Description
The Klaviyo.initialize() call crashes due to missing permissions that are not available when running an instant app. This can be easily reproduced on Android Studio when running the application as an instant app.
In the android documentation (https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle#configure-permissions), it says that we cannot use the permission CHANGE_NETWORK_STATE that is currently being used on the core module.
Stack Trace:
...
java.lang.SecurityException: x.x.x was not granted either of these permissions:android.permission.CHANGE_NETWORK_STATE,android.permission.WRITE_SETTINGS.
...
Caused by: java.lang.SecurityException: pt.napps.shop was not granted either of these permissions:android.permission.CHANGE_NETWORK_STATE,android.permission.WRITE_SETTINGS.
...
at com.klaviyo.core.networking.KlaviyoNetworkMonitor.initializeNetworkListener(KlaviyoNetworkMonitor.kt:120)
at com.klaviyo.core.networking.KlaviyoNetworkMonitor.onNetworkChange(KlaviyoNetworkMonitor.kt:54)
at com.klaviyo.analytics.networking.KlaviyoApiClient.startService(KlaviyoApiClient.kt:50)
at com.klaviyo.analytics.Klaviyo$initialize$1.invoke(Klaviyo.kt:69)
at com.klaviyo.analytics.Klaviyo$initialize$1.invoke(Klaviyo.kt:55)
at com.klaviyo.core.KlaviyoExceptionKt.safeCall(KlaviyoException.kt:23)
at com.klaviyo.core.KlaviyoExceptionKt.safeCall$default(KlaviyoException.kt:19)
at com.klaviyo.analytics.Klaviyo.initialize(Klaviyo.kt:55)
...
Expected behavior
For the SDK, to be able to run on instant apps.
Actual behavior
Currently, the SDK fails to initialize on instant apps.
Steps to reproduce
1. Create new project or reuse existing
2. Follow steps to run app as instant app https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle#test-from-studio
3. See stack trace
The Klaviyo Android SDK version information
3.0.0
Device Information
Pixel 8 Pro API 35
Android Studio Version
Android Studio Ladybug | 2024.2.1 Beta 1
Android API Level
API Level 35