mixpanel / mixpanel-flutter

Official Flutter Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
68 stars 75 forks source link

Doesn't run with Flutter: 3.24.3 #170

Open hamishnorton opened 3 weeks ago

hamishnorton commented 3 weeks ago

On launching a bare flutter project with the mixpanel_flutter package included it gives... Image

pubspec.yaml

name: flutterbuildtest
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0

environment:
  sdk: ^3.5.0

dependencies:
  flutter:
    sdk: flutter
  mixpanel_flutter: ^2.3.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^4.0.0

flutter:
  uses-material-design: true

flutter doctor -v

[✓] Flutter (Channel stable, 3.24.4, on macOS 14.6.1 23G93 darwin-arm64, locale en-NZ)
    • Flutter version 3.24.4 on channel stable at /Users/hamishnorton/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (6 days ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/hamishnorton/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.2)
    • 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 21.0.3+-79915917-b509.11)

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

[✓] Connected device (4 available)
    • SM G975F (mobile)               • R58M50YN1KA           • android-arm64  • Android 12 (API 31)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.6.1 23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.6.1 23G93 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 130.0.6723.91
    ! Error: Browsing on the local area network for Hamish’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
hamishnorton commented 3 weeks ago

I've resolved this issue (for now by configuring flutter to use Java 17).

It looks like Android Studio update installed Java 21 and by running: flutter create . I could see...

The configured version of Java detected may conflict with the Gradle version in your new Flutter app.

[RECOMMENDED] If so, to keep the default Gradle version 8.3, make
sure to download a compatible Java version
(Java 17 <= compatible Java version < Java 21).
You may configure this compatible Java version by running:
`flutter config --jdk-dir=<JDK_DIRECTORY>`
Note that this is a global configuration for Flutter.

Alternatively, to continue using your configured Java version, update the Gradle
version specified in the following file to a compatible Gradle version (compatible Gradle version range: 8.4 - 8.7):
/Users/hamishnorton/factory/flutter3244/android/gradle/wrapper/gradle-wrapper.properties

You may also update the Gradle version used by running
`./gradlew wrapper --gradle-version=<COMPATIBLE_GRADLE_VERSION>`.

See
https://docs.gradle.org/current/userguide/compatibility.html#java for details
on compatible Java/Gradle versions, and see
https://docs.gradle.org/current/userguide/gradle_wrapper.html#sec:upgrading_wrapper
for more details on using the Gradle Wrapper command to update the Gradle version
used.

I installed Java 17 from https://adoptium.net/temurin/releases/?os=mac&arch=any&version=17

Check it installed with: /usr/libexec/java_home -V

And set the flutter JDK directory with: flutter config --jdk-dir=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home

Upon running flutter doctor -v it shows Java 17. And on running flutter create --platform=android . the message has gone. And I can now launch the app.

What I am unsure about is that...

Android Studio Ladybug | 2024.2.1 Patch 1 Build #AI-242.23339.11.2421.12483815, built on October 11, 2024 Runtime version: 21.0.3+-79915917-b509.11 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.lwawt.macosx.LWCToolkit macOS 14.6.1 GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 2048M Cores: 8 Metal Rendering is ON Registry: ide.experimental.ui=true i18n.locale= Non-Bundled Plugins: Dart (242.22855.32) io.flutter (82.0.3)

Comes with Java 21 and this causes an issue for the mixpanel_flutter package. I've avoided the problem be pointing my flutter installation to Java 17 for now.