1

I'm trying to use Protobuf in my Android application. So to do that, I added the following lines in my gradle.build file :

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.5.0"
    }
}

apply plugin: "com.google.protobuf"

sourceSets {
        main {
            proto {
                // In addition to the default 'src/main/proto'
                srcDir '../../../Libs/Protocol'
            }
        }
    }

protobuf {
    protoc {
        path = '/usr/local/bin/protoc'
    }
}

The thing is I get an error when gradle builds. It says that :

Error:Execution failed for task ':app:generateDebugProto'.
> protoc: stdout: . stderr: protoc-gen-javanano: program not found or is not executable
  --javanano_out: protoc-gen-javanano: Plugin failed with status code 1.

Can you help me with this issue ? I have no idea of how to fix it.

Thank you in advance !

Alexandre D.
  • 711
  • 1
  • 9
  • 28
  • So you have application called protoc-gen-javanano in /usr/local/bin/protoc folder? – Selvin Jul 10 '15 at 15:35
  • No, I'm just giving the path for protoc in gradle. But I added the line in order to fix my issue and it didn't so I assume that it's not the reason. – Alexandre D. Jul 10 '15 at 15:37
  • You assumption is wrong... It is a path to protobuf binary – Selvin Jul 10 '15 at 15:38
  • Ok so without this line in my build.gradle I still have this error. Have you any idea about a possible solution? – Alexandre D. Jul 10 '15 at 18:53
  • Oh come on read the doc... Use this solutions which download the binaries... I think right before this solution... Or this solution, but change path to real path to protoc /protoc.exe (depends on platform Linux /windows) – Selvin Jul 10 '15 at 19:00

1 Answers1

1

This means that the version of protoc you're using doesn't support javanano. An easy fix would be to use pre-compiled protoc on Maven Central by adding the following to your build.gradle (as suggested by the documentation of the protobuf gradle plugin):

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.0.0-alpha-3'
    }
}
kku
  • 31
  • 4