【问题标题】: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 版本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-18
        • 2013-06-07
        • 2013-10-13
        • 1970-01-01
        相关资源
        最近更新 更多