skip to Main Content

I have already followed this answer to try fix this issue but no luck.

The build works 100% on iOS Simulator, but failing on Android Emulator with below:

The class is loaded from .gradle/caches/transforms-3/c3f0666cf8984b118654915928619821/transformed/jetified-kotlin-stdlib-1.9.0.jar!/kotlin/Unit.class
e: .pub-cache/hosted/pub.dev/stripe_android-9.6.0+2/android/src/main/kotlin/com/reactnativestripesdk/utils/Mappers.kt: (926, 7): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':stripe_android:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 33s

┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                     │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then │
│ update /wwwdir/doclink_ios/android/build.gradle:                         │
│ ext.kotlin_version = '<latest-version>'                                                    │
└────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

build.gradle file:

buildscript {
    ext.kotlin_version = '1.9.20'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

pubspec.yaml file:

name: doclink
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.1

environment:
  sdk: '>=2.18.5 <3.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependency_overrides:
  intl: ^0.18.1
  package_info_plus: ^4.0.1
  http: ^1.0.0

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.6

  firebase_core: ^2.4.1
  cloud_firestore: ^4.4.5
  firebase_messaging: ^14.5.0

  #------------  Service, Permission, Video, Image, State Management ------------#
  intl: ^0.17.0
  get: ^4.6.5
  permission_handler: ^10.2.0
  agora_rtc_engine: ^6.2.2
  shared_preferences: ^2.0.17
  image_picker: ^0.8.6+1
  video_thumbnail: ^0.5.3
  webview_flutter: ^4.4.4
  video_player: ^2.6.0
  timezone: ^0.9.1

  #------------  Google map ------------#
  google_maps_flutter: ^2.2.3
  geolocator: ^9.0.2

  #------------  UI ------------#
  intl_phone_number_input: ^0.7.2
  dotted_border: ^2.0.0+3
  table_calendar: ^3.0.8
  syncfusion_flutter_charts: ^20.4.38
  cached_network_image: ^3.2.3
  qr_code_scanner: ^1.0.1
  url_launcher: ^6.1.10
  flutter_rating_bar: ^4.0.1
  shimmer: ^2.0.0
  photo_view: ^0.14.0
  collection: ^1.17.0

  #------------  Notification ------------#
  flutter_local_notifications: ^14.0.0+1
  flutter_app_badger: ^1.5.0
  qr_flutter: ^4.1.0
  open_filex: ^4.3.4
  syncfusion_flutter_pdf: ^20.4.54
  flutter_stripe: ^9.4.0
  razorpay_flutter: ^1.3.5
  flutterwave_standard: ^1.0.8
  toggle_switch: ^2.1.0
  multiselect: ^0.1.0
  firebase_analytics: ^10.7.1
  signature: ^5.4.1
  device_preview: ^1.1.0
  flutter_paystack: ^1.0.7
  flutter_paypal: ^0.2.0
  firebase_auth: ^4.16.0
  

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
  generate: true
  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/
    - assets/icon/
    - assets/image/
    - assets/json/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: black
      fonts:
        - asset: assets/fonts/Montserrat-Black.ttf
    - family: bold
      fonts:
        - asset: assets/fonts/Montserrat-Bold.ttf
    - family: extraBold
      fonts:
        - asset: assets/fonts/Montserrat-ExtraBold.ttf
    - family: extraLight
      fonts:
        - asset: assets/fonts/Montserrat-ExtraLight.ttf
    - family: light
      fonts:
        - asset: assets/fonts/Montserrat-Light.ttf
    - family: medium
      fonts:
        - asset: assets/fonts/Montserrat-Medium.ttf
    - family: regular
      fonts:
        - asset: assets/fonts/Montserrat-Regular.ttf
    - family: semiBold
      fonts:
        - asset: assets/fonts/Montserrat-SemiBold.ttf
    - family: thin
      fonts:
        - asset: assets/fonts/Montserrat-Thin.ttf



  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages
flutter_intl:
  enabled: true

I’m hoping someone can give advice or feedback on how to fix this issue.

2

Answers


  1. You can try

    • Open your flutterApp/android folder in android studio

    for mac

    • run ./gradlew cleanBuildCache

    on Windows:

    • run gradlew cleanBuildCache

    • Invalidate caches.

    and let your gradle sync

    Login or Signup to reply.
  2. 1. Update Stripe

    Updating Flutter Stripe version in your pubspec.yaml file, you simply need change version number flutter_stripe dependency. Based on provided pubspec.yaml, current version ^9.4.0. Update it latest available version:

    dependencies:
      ...
      flutter_stripe: ^12.0.0
      ...
    

    This will update Flutter Stripe package version 12.0.0. After updating pubspec.yaml file, run flutter pub get in your terminal fetch update package latest version. Make sure check official Flutter Stripe documentation or release notes for any breaking changes or additional steps required for migration new version.

    2. Kotlin Update

    Regarding Kotlin version updating Gradle dependency in build.gradle file:

    In your build.gradle file, you have defined Kotlin version as 1.9.20:

    ext.kotlin_version = '1.9.20'
    

    This variable used specify version Kotlin plugin for Gradle, which applied project. Kotlin plugin allows you use Kotlin code within your Android project.

    3. Build Gradle update

    Updating com.android.tools.build:gradle:

    com.android.tools.build:gradle dependency in build.gradle file essential for building Android apps using Gradle.

    You have specified version 7.4.2 for this dependency:

    classpath 'com.android.tools.build:gradle:7.4.2'
    

    This dependency provides Android Gradle Plugin, which responsible for tasks such as compiling code, packaging APKs, managing dependencies in Android projects.

    You need update it gradle version 8.


    4. Java Update

    Unsupported class file major version 65

    Reason : wrong java version being used.

    Also downgrade java version 21 to 17. How? refer this link

    The correct version of Java is needed, here’s a list:

    Java SE 22 = 66,
    Java SE 21 = 65,
    Java SE 20 = 64,
    Java SE 19 = 63,
    Java SE 18 = 62,
    Java SE 17 = 61,
    Java SE 16 = 60, 
    Java SE 15 = 59,
    Java SE 14 = 58,
    Java SE 13 = 57,
    Java SE 12 = 56,
    Java SE 11 = 55,
    Java SE 10 = 54,
    Java SE 9 = 53,
    Java SE 8 = 52
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search