Android Studio - 无法加载内核绑定、无效的 SDK 哈希??(协议和飞镖)

Android Studio - Can't load kernel bindary, invalid SDK hash??(protoc and dart)

AS 中的问题片段

我可以从 proto 文件生成其他代码,但 dart 不能正常运行。有什么想法吗?谢谢!

  1. vi ~/.bash_profile
    add  export PATH="$PATH":"$HOME/.pub-cache/bin"
    source ~/.bash_profile
    
  2. flutter upgrade
    
  3. brew install protobuf
    
    brew tap dart-lang/dart
    
    brew install dart
    

which flutter
=> /Users/{UserName}/Applications/flutter/bin/flutter

rm /Users/{UserName}/Applications/flutter/bin/cache/flutter_tools.stamp

最后,重新打开终端。

发生问题是因为 protoc 二进制文件不是来自您的 flutter 二进制缓存,而是使用了另一个较旧的二进制文件。它可以来自 dart pub 缓存或系统上安装的以前的 flutter pub 缓存。

对于 Linux,您需要从系统中停用所有协议插件,然后再次激活它,然后使用安装的协议路径。

步骤如下:

  1. 为 dart 停用 protoc 插件:

    $ pub global deactivate protoc_plugin
    
  2. Flutter 的停用协议插件:

    $ flutter pub global deactivate protoc_plugin
    
  3. 激活 flutter 的 protoc 插件,这会将 proto 插件安装到你的 flutter 安装目录:

    $ flutter pub global activate protoc_plugin
    
  4. 对于Linux,将flutter安装目录的pub缓存路径添加到.bashrc。记得把/opt/flutter/改成你安装的目录:

    export PATH="$PATH:/opt/flutter/.pub-cache/bin:/opt/flutter/bin"
    
  5. 注销并重新登录以激活您的路径。