【问题标题】:Getting compile time error in audioplayers dart package在 audioplayers dart 包中出现编译时错误
【发布时间】:2021-08-23 20:44:49
【问题描述】:
我是 Flutter 的新手,我学习了 londonappbrewery 课程,在那门课程中,她教我们使用音频播放器包,所以我跟随她并将其导入 pubspec.yaml,但是当我想运行我的 Flutter 应用程序时,它给出了这个错误。请给出解决方案,我正在使用 Android 10 的物理设备上运行它。This is the error.
【问题讨论】:
标签:
flutter
dart
flutter-dependencies
flutter-packages
【解决方案1】:
您能否尝试以下方法,请确保您已使用 Kotlin 设置了 Android 项目,
此文件确保 Android 项目正在使用 Kotlin android/app/src/main/kotlin/com/example/your_app/MainActivity.kt
在android/build.gradle
buildscript {
ext.kotlin_version = '1.5.10' // Update this version or add this line
...
dependencies {
...
// Make sure this line is here
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
在android/app/build.gradle 中确保底部也有这条线,
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
在android/gradle/wrapper/gradle-wrapper.properties 中使用更新的gradle 版本gradle-6.5-bin.zip 用于distributionUrl
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
如果有任何困惑或问题,请发表评论。
【解决方案2】:
我认为可以通过将build.gradle 中的以下行更改为:
ext.kotlin_version = '1.3.50'
到
ext.kotlin_version = '1.4.32'
…或者任何可用的最新版本的 Kotlin。确保也更新 Android Studio 上的 Kotlin 版本。