natrium_wallet_flutter icon indicating copy to clipboard operation
natrium_wallet_flutter copied to clipboard

Cannot Build on M1 Mac

Open crypto-nerd-88 opened this issue 2 years ago • 1 comments

After installing Flutter and Gradle 6, successfully running flutter doctor, and installing NDK V21.1.6352462, I run:

flutter build apk

as per the instructions in the README, I get the following error:

Execution failed for task ':barcode_scan:generateReleaseProto'.
> Could not resolve all files for configuration ':**barcode_scan**:protobufToolsLocator_protoc'.
   > Could not find protoc-3.11.4-osx-aarch_64.exe (com.google.protobuf:protoc:3.11.4).
     Searched in the following locations:
         https://jcenter.bintray.com/com/google/protobuf/protoc/3.11.4/protoc-3.11.4-osx-aarch_64.exe

I even tried forking barcode_scan and changing some things according to some stackoverflow posts, but to no avail.

https://github.com/crypto-nerd-88/flutter_barcode_reader/blob/master/android/build.gradle

The protoc-gen-javalite causes issues and the jcenter repo no longer exists. Maybe you would consider using a different more modern qr scanner dependency??

Any plans on updating this repo so it can work with M1 Macs? It does work on an Intel Mac, BTW.

crypto-nerd-88 avatar May 02 '22 13:05 crypto-nerd-88

@crypto-nerd-88 Changing protoc & protoc-gen-javalite in build.gradle work for me.

// Configure the protoc executable
  protoc {
      // Download from repositories
      // For apple m1, add protoc_platform=osx-x86_64 in $HOME/.gradle/gradle.properties
      if (project.hasProperty('protoc_platform')) {
          artifact = "com.google.protobuf:protoc:3.11.4:${protoc_platform}"
      } else {
          artifact = "com.google.protobuf:protoc:3.11.4"
      }
  }
  plugins {
      javalite {
          // The codegen for lite comes as a separate artifact
          if (project.hasProperty('protoc_platform')) {
              artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0:${protoc_platform}"
          } else {
              artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
          }
      }
  }

Also add protoc_platform=osx-x86_64 in $HOME/.gradle/gradle.properties

hoanghn418 avatar May 22 '22 02:05 hoanghn418