urbanairship / airship-flutter

Flutter integration
Other
17 stars 16 forks source link

Can't migrate 4.3.0 to 5.0.1 #103

Closed kkoken closed 2 years ago

kkoken commented 2 years ago

Can't build the app when I try update the version to latest.

What Airship dependencies are you using?

airship_flutter 4.3.0 to 5.0.1 migration

What are the versions of any relevant development tools you are using?

Android Compile SDK 31
Kotlin version 1.4.32
Gradle 7.0.0

[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale en-TR)
    • Flutter version 2.5.3 at /Users/kaantahakoken/fvm/versions/2.5.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (7 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/kaantahakoken/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/kaantahakoken/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/kaantahakoken/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.62.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.28.0

[✓] Connected device (2 available)
    • Mi 9T (mobile) • c22e6ace • android-arm64  • Android 11 (API 30)
    • Chrome (web)   • chrome   • web-javascript • Google Chrome 96.0.4664.55
    ! Error: iPhone’u is not connected. Xcode will continue when iPhone is connected. (code -13)

• No issues found!

Report

What unexpected behavior are you seeing?

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDevDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)
     Duplicate class androidx.lifecycle.ViewModelProviderKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)
     Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
jyaganeh commented 2 years ago

Hi @kkoken,

I haven't been able to reproduce this issue by declaring that version of lifecycle-viewmodel-ktx in the android build.gradle in our flutter example app, so it looks like this may be due to clashing dependency versions being used in your app.

First, I'd check your gradle.properties file to make sure the following lines are included:

android.useAndroidX=true
android.enableJetifier=true

I'd also suggest running ./gradlew app:dependencies to see if you can identify what other dependency is requesting v2.4.0.

Normally, Gradle should be smart enough to resolve transitive dependencies without running into duplicate class issues, but you may need to either exclude or override the version to solve your issue. If you're able to find the other dependency and it's one that you're including manually in your build.gradle, you can exclude transitive dependencies like this:

dependencies {
    // ...

    implementation("com.example.yourdependency:yourdependency:1.2.3") {
        exclude group: "androidx.lifecycle"
    }
}

Otherwise, you can force Gradle to resolve a specific version of androidx.lifecycle by adding these lines above your dependencies block:

configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == "androidx.lifecycle") {
            details.useVersion "2.4.0"
        }
    }
}
kkoken commented 2 years ago

Hi @jyaganeh Thank you for replying and being cooperative. Lines mention below was already added.

android.useAndroidX=true
android.enableJetifier=true

However, I was able to solve my problem with these lines that you mentioned:

configurations.all {
    resolutionStrategy.eachDependency { details ->
        if (details.requested.group == "androidx.lifecycle") {
            details.useVersion "2.4.0"
        }
    }
}

Thank you for your help. Have a nice day.

kkoken commented 2 years ago

@jyaganeh I have encountered with different problem; but, this time was on iOS side

airship version: 5.0.1

Automatically signing iOS for device deployment using specified development team in Xcode project: xxxxxxxxxx
Xcode build done.                                           150.8s
(lldb) 2021-12-02 11:30:31.227502+0300 Gain[471:243455] GoogleCast framework version 4.6.1.19.00
Warning: Unable to create restoration in progress marker file
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x103ea21d0)
    frame #0: 0x0000000103ea21d0 AirshipKit`merged function signature specialization <Arg[1] = Dead> of generic specialization <AirshipKit.AnalyticsProtocol> of static AirshipKit.Airship.requireComponent<τ_0_0>(ofType: τ_0_0.Type) -> τ_0_0 + 240
AirshipKit`merged function signature specialization <Arg[1] = Dead> of generic specialization <AirshipKit.AnalyticsProtocol> of static AirshipKit.Airship.requireComponent<τ_0_0>(ofType: τ_0_0.Type) -> τ_0_0:
->  0x103ea21d0 <+240>: brk    #0x1
    0x103ea21d4 <+244>: brk    #0x1
AirshipKit`specialized Airship.deepLink(_:completionHandler:):
    0x103ea21d8 <+0>:   sub    sp, sp, #0xc0             ; =0xc0
    0x103ea21dc <+4>:   stp    x28, x27, [sp, #0x60]
Target 0: (Gain) stopped.
Error launching application on iPhone.
Exited (sigterm)
rlepinski commented 2 years ago

@kkoken is this a runtime exception or build exception? Kinda hard for me to make sense of that snippet

kkoken commented 2 years ago

After I fixed android side with the help of @jyaganeh, I decided to try iOS side. I plugged iPhone and try to run the app. The app build finished Xcode build done. 150.8s and immediately crashed @rlepinski .

rlepinski commented 2 years ago

Could you try 5.1.0 to see if the problem goes away?

kkoken commented 2 years ago

@rlepinski I moved 5.0.1 to 5.1.0, and android side works without any problem. I tried with iOS simulator (iPhone 12, iOS: 14.4) and it worked. However, I have not tried with physical device. I will check on Monday.

Have a nice weekend