customerio / customerio-flutter

Flutter plugin for Customer.io
https://www.customer.io/docs/sdk/flutter/getting-started/
MIT License
12 stars 10 forks source link

[ERROR:flutter/shell/common/shell.cc(1038)] The 'customer_io' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel. #121

Closed cmbellman closed 5 months ago

cmbellman commented 5 months ago

I'm getting the above error when running the CustomerIO.initialize function, targeting iOS simulator (I don't need push)

My initialization code in main.dart:

await CustomerIO.initialize(
    config: CustomerIOConfig(
        siteId: "[my_site_id]",
        apiKey: "[my_api_key]",
        region: Region.eu,
        //config options go here
        autoTrackDeviceAttributes: true,
        enableInApp: true,
        logLevel: CioLogLevel.debug,
    ),
  );

Flutter doctor: [✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-SE) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.3) [✓] IntelliJ IDEA Ultimate Edition (version 2023.1) [✓] VS Code (version 1.88.1) [✓] Connected device (4 available)
[✓] Network resources

cmbellman commented 5 months ago

Also may be related, I get this build error when trying to run it on my Samsung s22 ultra:

Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform tracking-3.10.0.aar (io.customer.android:tracking:3.10.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=25, org.gradle.category=library, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=androidJvm}.
      > Execution failed for DexingNoClasspathTransform: /Users/aad01/.gradle/caches/transforms-3/f8604d2da13633dfdcc647ce2f094253/transformed/jetified-tracking-3.10.0-runtime.jar.
         > Error while dexing.
Shahroz16 commented 5 months ago

Hey @cmbellman, thank you for reaching out, what gradle version are you using?

cmbellman commented 5 months ago

Hi @Shahroz16, my gradle version is Gradle 7.4.2

I'm on a mac m2 laptop, don't know if that matters though :)

emanuelnlopez commented 5 months ago

I'm also getting the same error as @cmbellman. I'm using gradle 7.6.3 on Macbook Pro i9

* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform tracking-3.10.0.aar (io.customer.android:tracking:3.10.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=androidJvm}.
      > Execution failed for DexingWithClasspathTransform: /Users/emanuel.lopez/.gradle/caches/transforms-3/febade0f6832fe187087078a47e39211/transformed/jetified-tracking-3.10.0-runtime.jar.
         > Error while dexing.

Steps to reproduce:

  1. I created a new app flutter create customer_io_test
  2. flutter pub add customer_io
  3. changed the following values in android/app/build.gradle:
    • compileSdk 34
    • minSdkVersion 23
    • targetSdkVersion 34

tried running the app

Shahroz16 commented 5 months ago

Thanks for more details folks, it looks similar to this issue could you try updating your minSdkVersion to 24 ?

This one looks even more related https://github.com/flutter/flutter/issues/144600#issuecomment-2074820649

cmbellman commented 5 months ago

I'm having minSdkVersion=25

Shahroz16 commented 5 months ago

Did you try out the solutions suggested in this GitHub issue?

Because this isn't specific to the CIO flutter SDK, you will face the same issue if you add any other dependency of google etc. This is related to how multi dex is happening in your application.

So I would suggest updating the Flutter version, maybe along with solutions suggested in the link above.

mrehan27 commented 5 months ago

Jumping into the discussion to see if I can help. Thanks for sharing the details. I just tested on new Flutter app using the commands shared above. I was able to run the app by simply updating minSdkVersion and Android Gradle Plugin version in settings.gradle file as follows:

id "com.android.application" version "7.4.1" apply false

Please make that you are checking the Android Gradle Plugin version in settings.gradle and not the Gradle version in the gradle-wrapper.properties.

Do let us know if you still face any issues or have more questions. Have a great day!

cmbellman commented 5 months ago

In settings.gradle I have

id "com.android.application" version "7.5.1" apply false

Also my compileSdkVersion is 34 becuase of some dependencies, but that shouldn't break anything right?

mrehan27 commented 5 months ago

Thanks for confirming. Unfortunately, Android Gradle Plugin 7.5.1 was never released, which could cause your app to not compile already. Can you please ensure that you are using the correct AGP version and follow these steps:

Let us know if you encounter any further issues.

cmbellman commented 5 months ago

That was it, downgrading to 7.4.1 fixed the issue! Thanks for the help!

emanuelnlopez commented 5 months ago

it also worked for me! thank you very much guys!

Shahroz16 commented 5 months ago

thanks for confirming folks!

cmbellman commented 5 months ago

Sorry for the confusion, the 7.5.1 wasn't our real gradle plugin version, it was just a snapshot of desperate trial and error changes of versions to try to find a working combo. We were indeed on 7.3.1 and it seems like 7.4.1 was needed in order to get things to work!

And for anyone coming here having the same problem, plugin version 7.4.1 requires gradle-wrapper.properties to specify distributionUrl for gradle version 7.5 (which may seem kinda confusing to some) :)

RoyalCoder88 commented 4 months ago

Sorry for the confusion, the 7.5.1 wasn't our real gradle plugin version, it was just a snapshot of desperate trial and error changes of versions to try to find a working combo. We were indeed on 7.3.1 and it seems like 7.4.1 was needed in order to get things to work!

And for anyone coming here having the same problem, plugin version 7.4.1 requires gradle-wrapper.properties to specify distributionUrl for gradle version 7.5 (which may seem kinda confusing to some) :)

Indeed this solution worked, I tried a lot of stuff and only this one worked, thanks!

Mirzogolib commented 2 months ago

if anyone still having issue similar to:

Execution failed for task :app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform tracking-3.10.0.aar (io.customer.android:tracking:3.10.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=25, org.gradle.category=library, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=androidJvm}.
      > Execution failed for DexingNoClasspathTransform: /Users/aad01/.gradle/caches/transforms-3/f8604d2da13633dfdcc647ce2f094253/transformed/jetified-tracking-3.10.0-runtime.jar.
         > Error while dexing.

If you do not want to update the Gradle version. There is a simple way to fix that issue. in pubspec.yaml just include 1.3.2 version of Customer IO which totally works with Gradle 7.5:

customer_io: 1.3.2

Hope that helps!

levibostian commented 2 months ago

Thanks for your continued support everyone.

Version 1.5.1 of the Flutter SDK has been deployed and includes a fix for this error message.

Please, give this new release a try. If you continue to receive this error message after install, send us a message with updated reproduction steps and we'll continue to look into it.

Thank you so much!