关于MAC M1处理器运行Android protoc报错的解决方案

Protobuf是Google开发的一种新的结构化数据存储格式,一般用于结构化数据的串行化,即我们常说的数据序列化。这种序列化的协议非常轻便高效,而且是跨平台的,目前已支持多种主流语言,并且比传统的XML, JSON等方式更具优势。详情可以参考:Google protocol buffer。不过,最近在使用Protobuf时候报了如下的一个错误。

Execution failed for task ':columbus:generateDebugProto'.
> Could not resolve all files for configuration ':columbus:protobufToolsLocator_protoc'.
   > Could not find protoc-3.0.0-osx-aarch_64.exe (com.google.protobuf:protoc:3.0.0).
     Searched in the following locations:
         https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-aarch_64.exe

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

解决的方法是更换protoc的地址,如果我们直接打开https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-aarch_64.exe,会发现网页时打不开,所以我就去掉后面的版本号,打开下面的链接:

https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/

得到protoc的版本如下:
在这里插入图片描述
所以,我们只需要找到下面的代码,在com.google.protobuf:protoc:3.0.0中添加osx-x86_64即可。

protoc {
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
    plugins {
        javalite {
            artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
        }
    }

//变更后
protoc {
        artifact = 'com.google.protobuf:protoc:3.0.0:osx-x86_64'
    }
    plugins {
        javalite {
            artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0:osx-x86_64'
        }
    }

猜你喜欢

转载自blog.csdn.net/xiangzhihong8/article/details/125553285