为属性'$ 4'指定的Flutter条形码扫描版本\条形码扫描\提取的原型\主要不存在

问题描述

我正在使用this软件包来扫描二维码。但是我升级到3.x版本,出现错误

[   +2 ms] FAILURE: Build Failed with an exception.
[   +2 ms] * What went wrong:
[        ] Some problems were found with the configuration of task ':barcode_scan:generateDebugProto'.
[        ] > Directory '<projectName>\build\barcode_scan\extracted-protos\main' specified for property '$4' does not exist.
[  +19 ms] * Try:
[  +17 ms] 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.

我尝试将main文件添加extracted-protos,但是当我运行应用程序时,该文件夹 丢失了。

解决方法

花了2天的时间修复它。最后,我弄清楚了如何:

转到android文件夹> build.gradle文件。添加行之后:

buildscript {
ext.kotlin_version = '1.3.61'
repositories {
    google()
    jcenter()
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12' //add this line
  }
}

而且有效。