Search code examples
flutterbarcodebarcode-scanner

Flutter (Barcode_scan) build\barcode_scan\extracted-protos\main' specified for property '$4' does not exist


I'm using this package to scan qr code. But I upgrade to 3.x version, have error:

[   +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.

I try add main folder to extracted-protos but when I run app, this folder is lost.


Solution

  • After spending 2 days trying to fix it. Finally I figured out how to:

    Go to android folder > build.gradle file. After add line:

    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
      }
    }
    

    And It work.