Search code examples
android-studioflutterdartprotoc

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


Snipit of the issue in AS

Snipit of the issue in AS

I can generate other code from proto files, but dart will not play nicely. Any thoughts? Thank you!


Solution

  • The problem is happened because the protoc binary is not from your flutter binary cache but using the other older one. It can be from dart pub cache or previous flutter pub cache installed on your system.

    For Linux, you need to deactivate all the protoc plugin from your system the activate it again then use the installed protoc path.

    Here the steps:

    1. Deactivate protoc plugin for dart:

      $ pub global deactivate protoc_plugin
      
    2. Deactive protoc plugin for flutter:

      $ flutter pub global deactivate protoc_plugin
      
    3. Activate protoc plugin for flutter, this will install proto plugin to your flutter installed directory:

      $ flutter pub global activate protoc_plugin
      
    4. For Linux, add pub cache path of your flutter installed directory to your .bashrc. Remember to change /opt/flutter/ to your installed directory:

      export PATH="$PATH:/opt/flutter/.pub-cache/bin:/opt/flutter/bin"
      
    5. Log out and login again to activate your path.