Execution failed for task ':qr_code_scanner:compileDebugKotlin' - flutter

I installed everything I needed following the instructions in https://docs.flutter.dev/get-started/install/windows. I believe that there is an error in the code, please tell me how to fix it?
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

Here is the solution: Change the version of qr_code_scanner in pubsec.yaml to 1.0.0!

try update kotlin_version to 1.7.10
and update com.android.tools.build:gradle to last varsion
then
flutter clean && flutter pub get

Related

FAILURE: Build failed with an exception. in Flutter project

Hello I am new to flutter , and I have this error while trying to run my project.
Can someone help me with it ?
Thank you.
If faced same issue, this solution worked for me
In android/build.gradle file:
in buildscript change the following:
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.13'
}
and in android\gradle\wrapper\gradle-wrapper.properties file:
add this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip

Flutter Execution failed for task ':stack_appodeal_flutter:compileDebugKotlin'. >

I tried to integrate Appodeal into my Flutter Project using latest stack_appodeal_flutter 1.2.0 Package.
I followed their instruction still got this error. Appreciate any help.
this is my Android build gradle
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://artifactory.appodeal.com/appodeal" }
}
}
If you have added
dependencies {
...
implementation 'com.appodeal.ads:sdk:2.11.0.+'
...
}
this in your build.gradle (module: app), please remove that and run again. Their documentation in pub.dev is little misunderstanding.

detect build error Incompatible classes were found in dependencies in flutter

it seems like a build or gradle setting error. Any thought of how to fix it?
[ +1 ms] e: Incompatible classes were found in dependencies. Remove
them from the classpath or use '-Xskip-metadata-version-check' to
suppress errors
This error will normally happen when the Kotlin version specified in your Android 'build.gradle' file is different from that bundled in Android Studio (or your preferred IDE in this case).
To solve it:
In Project Explorer of your Flutter project, navigate to android directory, and open build.gradle file.
NOTE: This is the overall 'build.gradle' file. Not the one inside the 'app' directory.
Your build.gradle file would look almost similar to the following snippet.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Your Kotlin version is marked by this line ext.kotlin_version = '1.3.50'.
This version needs to be same as the version of Kotlin bundled in the IDE. You can find the version of the bundled Kotlin by opening the 'Problems' tool window (can normally be found on the bottom left in Android Studio).
Update the version, and re-run the Flutter project.
Change kotlin version
buildscript {
ext.kotlin_version = "1.5.31"
check your kotlin version in warning section

Kotlin Gradle plugin

Hello for every one I have some problems in android sudio
[!] Your project requires a newer version of the Kotlin Gradle plugin.
Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update D:\flutter-programing\kidsgame\android\build.gradle:
ext.kotlin_version = ''
Exception: Gradle task assembleDebug failed with exit code 1
How can I make it?
enter image description here
You can do this change as shown in below image
So this was requirement with the new flutter update. Heres what you need to change.
From:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
To:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
}
You are simply needing to change the version number to the latest version available on Kotlin's website. Which as of t0day should be what i've put above. Just run flutter clean and flutter pub get after this and youre done.

I am trying to run my flutter app and I get this error every time , just upgraded flutter to 2.10.0 version [duplicate]

In Stripe, my client wants email and cardholder name, but the Stripe payment UI doesn't provide that option in com.stripe.android.view.CardMultilineWidget. I wanted to give it a try with the latest stripe version,
I was using Stripe version (14.1.1). So I updated it to the latest one (16.8.0)
The build showed me the error that it doesn't take minSdkVersion 19. It requires 21 in manifest merger. So I updated minSdkVersion to 21.
I got
caches/transforms-2/files-2.1/4541b0189187e0017d23bbb0afebd16a/jetified-kotlin-stdlib-common-1.5.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
I tried changing the Gradle version, but I am still getting the same error. How can I solve the incompatible error and add the email and cardholder name in Stripe?
Changing this in file build.gradle solved my problem.
From
ext.kotlin_version = '1.3.50'
to
ext.kotlin_version = '1.6.0'
Or whatever the latest version of Kotlin available and make sure to update Kotlin version on Android Studio as well.
I had this problem in a Flutter project.
In my case, a line for kotlin-gradle-plugin was missing in the Android build.gradle file, so adding ext.kotlin_version = '1.6.10' didn’t fix it.
After adding
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
the error was gone.
Full code section:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Although this question has been answered, I think it's worth explaining what is happening
For the example:
The binary version of its metadata is 1.7.1, expected version is 1.5.1.
The expected version is the Kotlin for kotlin-gradle-plugin
The binary version is the what is downloaded (or previously compiled)
for com.android.tools.build:gradle
<project_dir>/android/build.gradle
buildscript {
ext.kotlin_version = '1.5.20' // <= expected version is 1.5.1
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1' // downloads 1.7.1 Metadata
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <= 1.5.20 used here
Why is this Happening So Much?
The user updates the Kotlin version of the plugin to match the IDE version per the warning.
The user updates the android build tools gradle plugin per the warning
This is the WRONG version!
Now you don't have any warnings, but the version suggested is 7.1.3 which is not the latest. (I don't know why it suggests this older version) 7.3.1 is currently the latest and is meta data 1.7.1, so it will match the Kotlin version of 1.7.20 (which is also metadata 1.7.1)
What else could be wrong?
Due to caching, gradle may be using an older dependency before you updated. To start clean:
delete the ~/.gradle/cache directory
delete the android/.gradle directory
delete the project_dir/build dir
ensure the android/gradle/gradle-wrapper.properies has the correct distributionUrl (currently distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip)
from project_dir do flutter build apk
NOTE: your dependencies may need to be updated if their com.android.tools.build:gradle version is too old. Alternatively, both the kotlin and tools:gradle versions can be downgraded to compatible version that match metadata (although Android Studio will warn for that not matching the IDE Kotlin version)
How to Prevent this from happening Again?
Use the same Kotlin version as the IDE normally for ext.kotlin_version. see https://kotlinlang.org/docs/releases.html#release-details
Double check the com.android.tools.build:gradle version. See https://developer.android.com/studio/releases/gradle-plugin#updating-gradle and https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google
If you are facing this error in Flutter build for Android then try to change the Kotlin version to
ext.kotlin_version = '1.4.32'
Firstly, go to settings, and then navigate to plugins. Find the Kotlin plugin and update it.
Next, in gradle files, go to build.gradle (Project: YourApp). Then, change the following code (in buildscript) from:
ext.kotlin_version = '1.3.50'
to the latest version, such as:
ext.kotlin_version = '1.4.32'
To know the latest version, go to settings and the plugins, find the Kotlin plugin, and make sure it is updated. The latest version is under JetBrains.
After following the instructions, your error will be resolved.
Make sure that the Kotlin version of your IDE is the same as the version declared in your gradle.build file.
It was fixed by updating the Kotlin Gradle plugin version.
In the project level build.gradle file, update the following line.
ext.kotlin_version = '1.6.10'
You can find the latest Kotlin Gradle plugin version at
Tools / Build tools / Gradle.
Changed the Project build gradle to
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
What do you need to to solve this?
I was facing this issue since last night. Just navigate through some webpages couldn't get to the exact solution. I finally solved it by these steps:
Replace ext.kotlin_version = '1.3.50' with ext.kotlin_version = '1.4.32' in the build.gradle file.
Clean project → Build the project with Gradle files → Run
in my case for
The binary version of its metadata is 1.7.1, expected version is 1.5.1
got to (dependencies) inside build.gradle(project) convert from 1.5.x (x) in my case is (20)
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20"
to 1.7.10
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
Another solution is to downgrade androidx.core:core-ktx library to any compatible version. This one worked for kotlin_version = '1.3.31':
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.3.1' // The only working for this version (sdk/gradle)
implementation 'androidx.core:core-ktx:1.0.2' // The only working for this version (sdk/gradle)
implementation 'androidx.constraintlayout:constraintlayout:1.1.2' // higher versions require min-sdk >= 26
...
}
Android SDK: compileSdkVersion 30 and minSdkVersion 19.
Gradle build Tool: com.android.tools.build:gradle:3.3.1.
Just go to file build.gradle (Project: yourProjectName).
Change
plugins {
...
id 'org.jetbrains.kotlin.android' version '1.5.x' apply false
...
}
(1.5.x means x version number at your case, such as 1.5.1.)
To
plugins {
...
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
...
}
It works in my case...
Most of the answers here seem to revolve around projects that use Gradle.
I randomly encountered this problem in IntelliJ IDEA that that was compiling and running a Maven project just fine 5 minutes before - no configuration changes. I introduced a new exception class and this problem popped up.
I tried invalidating caches and restarting, which didn't resolve the issue - however, disabling and re-enabling the Kotlin plugin resolved the issue.
Using Flutter, it was fixed by:
Updating Android Studio packages, specially the Kotlin plugin.
Get the last Kotlin plugin version Nbr from Gradle - Plugin and versions. For now it's 1.6.10.
Update <Your_project_name_folder>\android\build.gradle file by replacing the old Kotlin version by the new one you got from the web site above.
ext.kotlin_version = '<The_new_version_Nbr>' in my case ext.kotlin_version = '1.6.10'
Restart Visual Studio Code.
You're done.
Go to the file build.gradle, change the version of kotlin.
In case in my flutter project I opened build.gradle and changed
`ext.kotlin_version = '1.5.30'`
to
ext.kotlin_version = '1.6.0'
Here
buildscript {
ext.kotlin_version = '1.6.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Then save and do
flutter clean and flutter run.
Works fine for me.
I faced the same problem in Flutter and I fixed it by going to:
File > Settings > Plugins as #Muzzamil said and I checked for the version of Kotlin in my IDE and simply replaced the value in ext.kotlin_version (that is 1.6.10) by that value
ext.kotlin_version = '1.6.10'
project build.gradle:
ext.kotlin_version = '1.6.10'
app/build.gradle:
dependencies {
// classpath 'com.android.tools.build:gradle:7.1.2'
// classpath "org.jetbrains.kotlin:kotlin-gradle- plugin:$kotlin_version"
}
But after changes ext.kotlin_version to lower this warning stay but the red warning is gone
For macOS you can
rm -r $HOME/.gradle/caches/
or you can invalidate caches
File >> Invalidate caches
I have the set minsdk 24 and restart the Android Studio, its working fine.
This works for me
buildscript {
ext.kotlin_version = '1.7.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
solution
A failure occurred while executing com.android.build.gradle.internal.tasks
Please check if you Kotlin version is compatible with compose version.
if not, then please make the changes and it should work fine.
Compose Compiler Version Compatible Kotlin Compiler Version
1.3.0 --> 1.7.10
1.3.0-rc01 --> 1.7.10
1.3.0-beta01 --> 1.7.10
1.2.0 --> 1.7.0
1.2.0-rc01 --> 1.6.21
1.2.0-beta03 --> 1.6.21
1.2.0-alpha08 --> 1.6.20
1.1.0 --> 1.6.10
1.1.1 --> 1.6.10
1.1.0-rc031.6.10
I upgraded the android studio version to the latest and that resolved the issue
I have faced this error in IntelliJ IDEA with a Maven project.
The solution is about to turn off Kotlin plugin in IntelliJ IDEA if you are not using Kotlin in your project.
Go to:
Menu File → Settings → Plugins
And turn off the Kotlin plugin by click on the checkbox. See here: