如何解决flutter项目编译调试Kotlin错误



我是颤振开发的新手。我在一个项目中使用了音频播放器:^0.19.0包,但当项目在模拟器上运行时,它会弹出大错误消息。你们能帮我解决这个问题吗?我不知道这是我的代码错误还是包问题。

任务":音频播放器:compileDebugKotlin"的执行失败。

编译错误。有关的更多详细信息,请参阅日志

import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Simple Music'),
backgroundColor: Colors.amber[300],
),
body: SafeArea(
child: Center(
child: TextButton(
child: Text("music"),
onPressed: () {
final player = AudioCache();
player.play("note2.wav");
},
),
),
),
),
);
}
}

调试控制台

Launching libmain.dart on AOSP on IA Emulator in debug mode...
e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: C:/Users/acer/.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: C:/Users/acer/.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: C:/Users/acer/.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: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersAudioplayersPlugin.kt: (18, 32): Unresolved reference: mutableMapOf
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersAudioplayersPlugin.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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersAudioplayersPlugin.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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersAudioplayersPlugin.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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersAudioplayersPlugin.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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (127, 13): 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (129, 9): Unresolved reference: synchronized
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (130, 18): 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (131, 59): Unresolved reference: mutableListOf
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (136, 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (137, 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (143, 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (144, 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (154, 14): 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (156, 23): Unresolved reference: let
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (156, 39): 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (156, 49): Unresolved reference: it
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (161, 14): 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (163, 23): Unresolved reference: let
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (163, 39): 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 C:/Users/acer/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/kotlin/Unit.class
e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.kt: (163, 47): Unresolved reference: it

e: C:FlutterFlutterFlutter_sdk.pub-cachehostedpub.dartlang.orgaudioplayers-0.19.0androidsrcmainkotlinxyzluanaudioplayersWrappedSoundPool.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 C:/Users/acer/.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 1m 50s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

尝试更改build.gradle文件(位于项目的android文件夹中(中的ext.kotlin_version值,如下所示:

buildscript {
ext.kotlin_version = '1.5.10'

repositories {
google()
jcenter()
}
dependencies{
...
}
}

相关内容

  • 没有找到相关文章

最新更新