-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using global context when creating a tracker causes crashes on API 23 #601
Comments
Hi @frodstan, I think this is caused by the fact that the global context implementation uses Java 8 features underneath. In order to make this work on older Android SDKs, you will need to add Java 8 desugaring support to your app. You can follow the instructions here. Basically you need to use Android Gradle Plugin v4 and add this to your android {
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
} You can see the Hope this helps! Let us know if you run into any problems. |
Awesome, this fixed the issue. |
Hi @matus-tomlein , I know that this problem is already "solved" using the proposed workaround, but Is there any other way to do it that does not involve having to add another dependency other than snowplow? I´d prefer not having to include this third dependency |
…on of FocalMeterConfiguration would crash. A thread (snowplow#601) in the issue tracker suggested to use of coreLibraryDesugaring but this might be avoided. remove usage of java.util.function.* in order to get rid of library desugaring.
Describe the bug
Initializing the sdk with a global context on Android 6 throws an exception. I have tried both with a static context and with context generator.
FATAL EXCEPTION: main Process: com.example.snowplow_test, PID: 17105 java.lang.NoClassDefFoundError: com.snowplowanalytics.core.globalcontexts.GlobalContextPluginConfiguration$$ExternalSyntheticLambda0 at com.snowplowanalytics.core.globalcontexts.GlobalContextPluginConfiguration.getEntitiesConfiguration(GlobalContextPluginConfiguration.kt:28) at com.snowplowanalytics.snowplow.configuration.PluginConfigurationKt.toStateMachine(PluginConfiguration.kt:62) at com.snowplowanalytics.core.tracker.ServiceProvider$makeTracker$builder$1.invoke(ServiceProvider.kt:293) at com.snowplowanalytics.core.tracker.ServiceProvider$makeTracker$builder$1.invoke(ServiceProvider.kt:262) at com.snowplowanalytics.core.tracker.Tracker.<init>(Tracker.kt:356) at com.snowplowanalytics.core.tracker.ServiceProvider.makeTracker(ServiceProvider.kt:297) at com.snowplowanalytics.core.tracker.ServiceProvider.getOrMakeTracker(ServiceProvider.kt:187) at com.snowplowanalytics.core.tracker.ServiceProvider.<init>(ServiceProvider.kt:87) at com.snowplowanalytics.snowplow.Snowplow.createTracker(Snowplow.kt:237) at com.example.snowplow_test.MainActivity.initializeSnowplow(MainActivity.kt:68) at com.example.snowplow_test.MainActivity.onCreate(MainActivity.kt:37)
To Reproduce
To reproduce this issue, create a new Android app from template with minimum Android SDK 23.
Add snowplow library (version 5.0.0 - 5.1.0, 4.x.x has worked for us previously).
Initialize the sdk in MainActivity onCreate() with a global context sent to Snowplow.createTracker()
Pasting in from documentation here will cause the crash:
https://docs.snowplow.io/docs/collecting-data/collecting-from-own-applications/mobile-trackers/custom-tracking-using-schemas/global-context/#static-entities
Run the app on a device or emulator with Android 6
Expected behavior
Snowplow will have initialized and is ready to send events
Device information (please complete the following information):
The text was updated successfully, but these errors were encountered: