解决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/这个仓库下就没有protoc-3.0.0-osx-aarch_64.exe这个文件

解决方案是修改协议地址。如果我们直接打开https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-osx-aarch_64.exe,我们会发现网页无法打开,所以我将删除版本号并打开以下链接:

因此,我们只需要找到下面的代码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'
     }
 }
相关推荐
YM52e3 小时前
鸿蒙Flutter Padding内边距:EdgeInsets详解
android·学习·flutter·华为·harmonyos·鸿蒙
Rex叶然7 小时前
ScreenMatch适配安卓屏幕脚本,用于老项目
android·screenmatch·安卓屏幕适配
阿pin7 小时前
Android随笔-Activity启动流程深度分析
android·activity启动流程
zzq77978 小时前
加固包闪退四象限定位:targetSdk 与保护策略实战解析
android·安全·安卓·安全架构
我命由我123459 小时前
Android 开发问题:Cannot resolve method ‘repeat‘ in ‘String‘
android·java·java-ee·android studio·android jetpack·android-studio·android runtime
光头闪亮亮10 小时前
Fyne ( go跨平台GUI )项目实战-scanner摄像头扫码组件开发技术详解
android·go
Android打工仔10 小时前
Continuation 到底是谁创建的?
android·kotlin
DeepAgent11 小时前
AI Agent 工程实践(17):Agent 为什么需要可观测性(Observability)?
android·llm·agent
提笔了无痕11 小时前
MySQL SQL 从 EXPLAIN 到索引优化,搞懂 SQL 为什么慢
android·sql·mysql
2601_9609067211 小时前
科技“无人区”跋涉,难度高、不确定性大
windows·macos·pycharm·myeclipse