我有一个需要使用protobuf的项目(从服务器获取对象并解析它们)。 为此,我配置了以下内容:
项目级别gradle.build
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' classpath 'com.google.protobuf:protobuf-java:2.6.1' } } allprojects { repositories { jcenter() mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir }应用程序级别gradle.build
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.protobuf' android { ... } protobuf { protoc { artifact = 'com.google.protobuf:protoc:2.6.1' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.google.protobuf:protobuf-java:2.6.1' compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' }我把我的proto文件放在.../app/src/main/proto/FILE.proto 。 一旦我正在尝试构建该项目,我收到以下错误:
Error:Execution failed for task ':app:generateDebugProto'. > protoc: stdout: . stderr: /Users/XX/YY/app/build/extracted-protos/main: warning: directory does not exist. /Users/XX/YY/app/build/extracted-include-protos/main: warning: directory does not exist. ... protoc-gen-javanano: program not found or is not executable --javanano_out: protoc-gen-javanano: Plugin failed with status code 1.任何想法为什么是这样? 它应该使用repo中的protoc,并且应该支持该纳米编译。
谢谢。
I have a project that need to use protobuf (Getting the objects from server and parsing them). For that I configured the following things:
Project level gradle.build
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' classpath 'com.google.protobuf:protobuf-java:2.6.1' } } allprojects { repositories { jcenter() mavenCentral() } } task clean(type: Delete) { delete rootProject.buildDir }App level gradle.build
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.protobuf' android { ... } protobuf { protoc { artifact = 'com.google.protobuf:protoc:2.6.1' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.google.protobuf:protobuf-java:2.6.1' compile 'com.google.protobuf:protobuf-gradle-plugin:0.7.0' }I put my proto file under .../app/src/main/proto/FILE.proto. Once i am trying to build the project I am getting the following error:
Error:Execution failed for task ':app:generateDebugProto'. > protoc: stdout: . stderr: /Users/XX/YY/app/build/extracted-protos/main: warning: directory does not exist. /Users/XX/YY/app/build/extracted-include-protos/main: warning: directory does not exist. ... protoc-gen-javanano: program not found or is not executable --javanano_out: protoc-gen-javanano: Plugin failed with status code 1.Any idea why is that? It should use the protoc from the repo and is should support that nano compilation.
Thanks.
最满意答案
最后我从GitHub下载了源代码并编译了它。 它解决了这个问题,因为它包含缺少的二进制文件
Finally i downloaded the source from GitHub and compiled it. It fixed the issue because it includes the missing binary.
更多推荐
发布评论