'Execution failed for task ':audioplayers:compileDebugKotlin'
I'm facing this nasty error when trying to compile my Flutter App into an Android simulator. Here is the error log (is too long to paste it entirely):
aunching lib/main.dart on sdk gphone x86 in debug mode... Running Gradle task 'assembleDebug'... Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors e: /Users/reinier/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/META-INF/kotlin-stdlib.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. e: /Users/reinier/.gradle/caches/transforms-2/files-2.1/4d4ccf1034ba5937e6e7ba3aa34d2661/jetified-core-ktx-1.6.0-beta02-api.jar!/META-INF/core-ktx_release.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. e: /Users/reinier/.gradle/caches/transforms-2/files-2.1/77bab1911042ab2c6d5cc0b2e2ee053c/jetified-kotlin-stdlib-common-1.5.10.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. e: /Users/reinier/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt: (18, 32): Unresolved reference: mutableMapOf e: /Users/reinier/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt: (25, 9): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
. . . . .
e: /Users/reinier/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/WrappedSoundPool.kt: (235, 30): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15. The class is loaded from /Users/reinier/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':audioplayers:compileDebugKotlin'.
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 21s Exception: Gradle task assembleDebug failed with exit code 1
- I already tried changing "minSdkVersion 16" to "minSdkVersion 23" at android/app/build.gradle:38 and is not working.
- Tried using the version 0.17.0 of audioplayers and the same, not working.
- Tried using the version ^0.10.0 of audioplayers and nothing.
- Tried doing the previos steps and then executing on the terminal: flutter clean & flutter pub get... and nothing.
- I already updated the Flutter SDK and nothing. Still not working for Android.
It compiles perfectly on an IOS simulator. This error has emerged several times after each audioplayers package update. I'm using compileSdkVersion 30 on Android Studio 4.2.1
This is my pubspec.yaml file:
name: feeddy_flutter
description: A multi screen foods listing Flutter app
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
intl: ^0.17.0
uuid: ^3.0.4
currency_text_input_formatter: ^2.0.1
date_time_picker: ^2.0.0
rflutter_alert: ^2.0.2
faker: ^1.3.0
fl_chart: ^0.35.0
provider: ^5.0.0
tinycolor: ^1.0.3
font_awesome_flutter: ^9.0.0
audioplayers: ^0.18.3
empty_widget: ^0.0.2
splashscreen: ^1.3.5
native_device_orientation: ^1.0.0
sqflite: ^2.0.0+3
flutter_switch: ^0.3.1
flutter_colorpicker: ^0.4.0
enum_to_string: ^2.0.1
humanizer: ^0.0.2
route_observer_mixin: ^1.5.0+1
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/images/
- assets/audio/
fonts:
- family: Luminari
fonts:
- asset: assets/fonts/Luminari/Luminari-Regular.ttf
style: normal
weight: 500
- asset: assets/fonts/Luminari/Luminari-Regular.woff
style: normal
weight: 500
- family: SourceSansPro
fonts:
- asset: assets/fonts/Source_Sans_Pro/SourceSansPro-Regular.ttf
style: normal
weight: 500
- family: OpenSans
fonts:
- asset: assets/fonts/OpenSans/OpenSans-Regular.ttf
style: normal
weight: 500
- asset: assets/fonts/OpenSans/OpenSans-Bold.ttf
weight: 700
- family: Quicksand
fonts:
- asset: assets/fonts/Quicksand/Quicksand-Regular.ttf
style: normal
weight: 500
- asset: assets/fonts/Quicksand/Quicksand-Medium.ttf
- asset: assets/fonts/Quicksand/Quicksand-Light.ttf
- asset: assets/fonts/Quicksand/Quicksand-Bold.ttf
weight: 700
- family: Raleway
fonts:
- asset: assets/fonts/Raleway/Raleway-Regular.ttf
style: normal
weight: 500
- asset: assets/fonts/Raleway/Raleway-Bold.ttf
weight: 700
- asset: assets/fonts/Raleway/Raleway-Black.ttf
weight: 900
- family: RobotoCondensed
fonts:
- asset: assets/fonts/RobotoCondensed/RobotoCondensed-Regular.ttf
style: normal
weight: 500
- asset: assets/fonts/RobotoCondensed/RobotoCondensed-Bold.ttf
weight: 700
- asset: assets/fonts/RobotoCondensed/RobotoCondensed-Light.ttf
weight: 300
- asset: assets/fonts/RobotoCondensed/RobotoCondensed-Italic.ttf
style: italic
- family: AppIcons
fonts:
- asset: assets/fonts/AppIcons/AppIcons.ttf
Solution 1:[1]
Updating to a newer kotlin version in build.gradle
seems to solve the issue for me.
ext.kotlin_version = '1.4.32'
Solution 2:[2]
this happened to me after i added the workmanager plugin. to fix this, go to the android folder and in build.gradle use kotlin version 1.5.31
ext.kotlin_version = '1.5.31'
Solution 3:[3]
Please open android > build.gradle
Inside buildscript { }
, you'll find ext.kotlin_version
(Line 2 in file)
Replace whatever version it is with Latest Stable Kotlin Version
As of July 28, 2021 it is, ext.kotlin_version = '1.5.21'
Now, re-install the app. If it's already running, press Stop then press Run (Play) again.
Solution 4:[4]
Go to android>build.gradle and update your Kotlin version.
ext.kotlin_version = '1.4.32'
This worked for me.
Solution 5:[5]
As for Flutter 2.10
there was a breaking change with required Kotlin
version - Ref.
Here is a migration guide
This means that if you previosly created a project a long time ago (with java) then it means you need to add Kotlin plugin
to build.gradle
. I suggest launching flutter create --org com.sample sample
which generates up-to-date configuration. Then you can check what is missing.
Solution 6:[6]
this happened to me after i added the Room plugin. to fix this, go to the android folder and in build.gradle use kotlin version 1.5.31
I changed from
ext { kotlin_version = "1.3.72" nav_version = "2.3.1"
room_version = '2.3.0' }
replace with
ext { kotlin_version = "1.5.31" nav_version = "2.3.1" room_version = '2.3.0' }
Solution 7:[7]
Plese check the current kotlin (installed) version by
ANdroidstudio->Preferences->Languages& frameworks->kotlin
In this 1.6.10 is the version . Now Open Android build.gradle
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
.....
Change it ..
ext.kotlin_version** = '1.6.10'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | bakavic |
Solution 2 | |
Solution 3 | Boaz |
Solution 4 | Rozi khan |
Solution 5 | Micha? Dobi Dobrza?ski |
Solution 6 | Subratsss |
Solution 7 |