出現(xiàn)問題:
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: /Users/user/.gradle/caches/transforms-2/files-2.1/2ea2c8b52f906f98d5deda90cfed9dad/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/user/.gradle/caches/transforms-2/files-2.1/3b0753969d68ffd5874e4b39343d65d1/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/user/.gradle/caches/transforms-2/files-2.1/d03ac8f4b530d2e19911a538ea8e8ac4/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/user/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt: (18, 32): Unresolved reference: mutableMapOf
e: /Users/user/.pub-cache/hosted/pub.flutter-io.cn/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.
The class is loaded from /Users/user/.gradle/caches/transforms-2/files-2.1/3b0753969d68ffd5874e4b39343d65d1/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: /Users/user/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt: (26, 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.
The class is loaded from /Users/user/.gradle/caches/transforms-2/files-2.1/3b0753969d68ffd5874e4b39343d65d1/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: /Users/user/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt: (27, 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.
The class is loaded from /Users/user/.gradle/caches/transforms-2/files-2.1/3b0753969d68ffd5874e4b39343d65d1/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: /Users/user/.pub-cache/hosted/pub.flutter-io.cn/audioplayers-0.18.3/android/src/main/kotlin/xyz/luan/audioplayers/AudioplayersPlugin.kt: (28, 17): 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/user/.gradle/caches/transforms-2/files-2.1/3b0753969d68ffd5874e4b39343d65d1/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':audioplayers:compileReleaseKotlin'.
> 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 23s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 24.7s
解決方案:
方案1:
在您的項(xiàng)目級(jí) gradle 文件中抱慌,只需將 ext.kotlin.version 從您擁有的任何版本增加到“1.4.32”或任何可用的最新版本。
路徑:/android/build.gradle
示例:
buildscript {
ext.kotlin_version = '1.4.32'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}