juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
782 stars 460 forks source link

Error when building app:checkDebugDuplicateClasses #957

Open dordzhiev opened 5 months ago

dordzhiev commented 5 months ago
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.io.path.DirectoryEntriesReader found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.FileVisitorBuilder found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.FileVisitorBuilderImpl found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.FileVisitorImpl found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.LinkFollowing found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathNode found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalk found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalk$bfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalk$dfsIterator$1 found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathTreeWalkKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathWalkOption found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk7-1.7.22 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.22)
     Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.jvm.optionals.OptionalsKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and jetified-kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)

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

* 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 37s
Exception: Gradle task assembleDebug failed with exit code 1
dordzhiev commented 5 months ago

compileSdkVersion 34 minSdkVersion 21

navaronbracke commented 5 months ago

You are running on Kotlin 1.8.22 ?

Could you provide your build.gradle? I think this is an issue with your dependencies.

dordzhiev commented 5 months ago

You are running on Kotlin 1.8.22 ?

Could you provide your build.gradle? I think this is an issue with your dependencies.

This is a project from scratch

    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "..."
//    compileSdkVersion flutter.compileSdkVersion
    compileSdkVersion 34
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "..."
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
//        minSdkVersion flutter.minSdkVersion
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {}
dordzhiev commented 5 months ago

Only version 3.5.5 works for me

f1shy-dev commented 5 months ago

After looking around online for ages, the fix(es) that worked for me (with version ^4.0.0 were these changes in my build.gradle:

Setting sdk version to 34 and compile options to java 17

compileSdkVersion 34
compileSdk 34

compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

// down below

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 34
}

and adding this to my dependencies (not sure if this helps), along with this configurations block

dependencies {
    implementation 'com.google.guava:guava:28.2-android'
}

// I put this block in both build.gradle and android/build.gradle... no clue what it does though...
configurations.all {
    resolutionStrategy {
        force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22'
    }
}

And then I ran flutter clean and then I was able to run!

(I am no expert, I literally copy pasted every solution for this issue that I found and it eventually worked, hope this helps somebody?)

navaronbracke commented 5 months ago

The compileSdk version 34 and Java 17 changes are indeed intentional. See the changelog here https://github.com/juliansteenbakker/mobile_scanner/blob/master/CHANGELOG.md#400

I'm not exactly sure for what you need the guava dependency (I do recall it being needed for something very specific related to some Java Futures API which isn't included in the Android SDK)

For the org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22, it seems that some of your dependencies force you to do that? The mobile_scanner package already uses Kotlin 1.9.x

Side note: you shouldn't need kotlin-stdlib-jdk8 specifically, as the stdlib for jdk 7 and 8 have been merged into one. So you should be able to just depend on kotlin-stdlib-jdk.

tsukifell commented 4 months ago

After looking around online for ages, the fix(es) that worked for me (with version ^4.0.0 were these changes in my build.gradle:

Setting sdk version to 34 and compile options to java 17

compileSdkVersion 34
compileSdk 34

compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

// down below

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 34
}

and adding this to my dependencies (not sure if this helps), along with this configurations block

dependencies {
    implementation 'com.google.guava:guava:28.2-android'
}

// I put this block in both build.gradle and android/build.gradle... no clue what it does though...
configurations.all {
    resolutionStrategy {
        force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22'
    }
}

And then I ran flutter clean and then I was able to run!

(I am no expert, I literally copy pasted every solution for this issue that I found and it eventually worked, hope this helps somebody?)

Thank you, i was having the same problem and this does work for me

PROJASO commented 4 months ago

It’s exactly what @navaronbracke mentioned, update the compileSdk version to 34 and Java to 17, then you have to make sure you are using Kotlin version 1.8.22, this is modified in the build.gradle of the root directory of android, in the ‘ext.kotlin_version’ option, and that's all.

mateusdalmeida commented 4 months ago

I have the same problem, running on a computer recently configured for flutter.

WINDOWS 11 JAVA ORACLE: 17.0.10 ANDROID SDK: 34 FLUTTER 3.19

the problem is reproducible even in the example application

I believe that if the problem occurs even in the minimum configurations, it is something on the package side and not in my settings

PROJASO commented 4 months ago

I have the same problem, running on a computer recently configured for flutter.

WINDOWS 11 JAVA ORACLE: 17.0.10 ANDROID SDK: 34 FLUTTER 3.19

the problem is reproducible even in the example application

  • flutter create example
  • flutter pub add mobile_scanner
  • update minSdkVersion to 21
  • flutter build apk

I believe that if the problem occurs even in the minimum configurations, it is something on the package side and not in my settings

By default, when you create a Flutter app, the Kotlin version is 1.7.10 and (i guess) mobile_scaner needs a higher Kotlin version, i just tried with 1.8.22 and it works for me.

navaronbracke commented 4 months ago

I believe that if the problem occurs even in the minimum configurations, it is something on the package side and not in my > settings

If you were to update your dependencies, which would probably state versioning requirements in their changelogs (i.e. requiring a minSdk of 23), and you do forget to update your minimum SDK versions and such, that is a problem in your local project settings?

Pezhvak commented 4 months ago

This is my solution:

Add these lines to android/local.properties:

flutter.minSdkVersion=21
flutter.targetSdkVersion=34

Then open android/app/build.gradle and change these lines:

//        minSdkVersion flutter.minSdkVersion
        minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
//        targetSdkVersion flutter.targetSdkVersion
        targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()

And in the same file (android/app/build.gradle): add this lines at the end:

configurations.all {
    resolutionStrategy {
        eachDependency {
            if ((requested.group == "org.jetbrains.kotlin") && (requested.name.startsWith("kotlin-stdlib"))) {
                useVersion("1.8.0")
            }
        }
    }
}

Hope it helps you.

GerardGekyo commented 4 months ago

Great, it worked for me!

But it is normal to have this message every time the camera is activated.

Access denied finding property "ro.hardware.chipname"

Thank you!

DevLeti commented 4 months ago

After looking around online for ages, the fix(es) that worked for me (with version ^4.0.0 were these changes in my build.gradle:

Setting sdk version to 34 and compile options to java 17

compileSdkVersion 34
compileSdk 34

compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

// down below

defaultConfig {
    minSdkVersion 21
    targetSdkVersion 34
}

and adding this to my dependencies (not sure if this helps), along with this configurations block

dependencies {
    implementation 'com.google.guava:guava:28.2-android'
}

// I put this block in both build.gradle and android/build.gradle... no clue what it does though...
configurations.all {
    resolutionStrategy {
        force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22'
    }
}

And then I ran flutter clean and then I was able to run!

(I am no expert, I literally copy pasted every solution for this issue that I found and it eventually worked, hope this helps somebody?)

Thank you, this worked for me. I changed/added some code in app/build.gradle &

  1. changed minSdkVersion from flutter.minSdkVersion to 21
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.camera_test"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    //        minSdkVersion flutter.minSdkVersion
        minSdkVersion 21
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
  2. added code at the bottom
    configurations.all {
    resolutionStrategy {
        force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22'
    }
    }

    I found another solution.

  3. Change minSdkVersion to 21 is same.
  4. Change org.jetbrains.kotlin.android plugin's version to 1.8.22 in android/setting.gradle.
    plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "7.3.0" apply false
    //    id "org.jetbrains.kotlin.android" version "1.7.10" apply false // before
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false // after
    }

    from flutter 3.16, kotlin version option is moved to settings.gradle. So I think this is better way to resolve the problem. Check here: Stack Overflow flutter docs FYI)My flutter version is 3.19.2, dart is 3.3.0

diegonc commented 3 months ago

I found another solution.

  1. Change minSdkVersion to 21 is same.
  2. Change org.jetbrains.kotlin.android plugin's version to 1.8.22 in android/setting.gradle.

These two are the minimum changes to make mobile_scanner:4.0.1 work on an otherwise empty project. My current setup is:

> flutter doctor -v
[✓] Flutter (Channel stable, 3.19.5, on Microsoft Windows [Versi¢n 10.0.22631.3447], locale es-AR)
    • Flutter version 3.19.5 on channel stable at D:\diego\PROGRAMACION\Tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (2 weeks ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at D:\diego\PROGRAMACION\SDKs\Android
    • Platform android-34, build-tools 33.0.1
    • Java binary at: D:\diego\PROGRAMACION\Tools\android-studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✗] Visual Studio - develop Windows apps
    ✗ Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[✓] Android Studio (version 2023.2)
    • Android Studio at D:\diego\PROGRAMACION\Tools\android-studio
    • 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 17.0.9+0--11185874)

[✓] VS Code (version 1.88.0)
    • VS Code at C:\Users\diego\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Versi¢n 10.0.22631.3447]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 123.0.6312.106
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 123.0.2420.65

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

! Doctor found issues in 1 category.
hasnain1230 commented 2 months ago

This is my solution:

Add these lines to android/local.properties:

flutter.minSdkVersion=21
flutter.targetSdkVersion=34

Then open android/app/build.gradle and change these lines:

//        minSdkVersion flutter.minSdkVersion
        minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
//        targetSdkVersion flutter.targetSdkVersion
        targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()

And in the same file (android/app/build.gradle): add this lines at the end:

configurations.all {
    resolutionStrategy {
        eachDependency {
            if ((requested.group == "org.jetbrains.kotlin") && (requested.name.startsWith("kotlin-stdlib"))) {
                useVersion("1.8.0")
            }
        }
    }
}

Hope it helps you.

In my experience, I did not need to make any of the changes except for this...

configurations.all {
    resolutionStrategy {
        eachDependency {
            if ((requested.group == "org.jetbrains.kotlin") && (requested.name.startsWith("kotlin-stdlib"))) {
                useVersion("1.8.22")
            }
        }
    }
}

I was even able to leave the flutter.targetSdkVersion... I simply changed to minSdkVersion 21 and added the config above and it worked just fine for me. Hope it can help someone else too implement a simplified fix.

MohmaedSobhy commented 1 month ago

thank you this work for me

AndresH11 commented 2 weeks ago

To solve the error you must go to the settings.gradle file and in the next line make the following change

plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.0" apply false id "org.jetbrains.kotlin.android" version "1.8.22" apply false // before id "org.jetbrains.kotlin.android" version "1.7.10" apply false }

GMars7502 commented 1 week ago

It worked for me this way (firebase was used) "plugins { id "com.android.application" // START: FlutterFire Configuration id 'com.google.gms.google-services' // END: FlutterFire Configuration id "kotlin-android" id "dev.flutter.flutter-gradle-plugin" }

def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } }

def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' }

def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' }

android { namespace "com.gatovolador.pruebafirebase" compileSdk 34 //flutter.compileSdkVersion ndkVersion flutter.ndkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_17
    targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
    jvmTarget = '1.8'
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.gatovolador.pruebafirebase"
    // You can update the following values to match your application needs.
    // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
    // aqui se cambio el minSdkVersion a la version 21
    minSdkVersion 21
    targetSdkVersion 34 //flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
}

}

flutter { source '../..' }

dependencies { implementation 'com.google.guava:guava:28.2-android' }

configurations.all { resolutionStrategy { force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22' } } "