【问题标题】:Unable to resolve x imports无法解析 x 导入
【发布时间】:2019-12-11 17:03:30
【问题描述】:

我得到(使用:api 'com.squareup.wire:wire-runtime:3.0.2')

Execution failed for task ':app:generateProtos'.
unable to resolve 1 imports: testing/tastes/tastes.proto
searching 0 proto paths:

我的理解是我不需要在 gradle 中定义任何东西来寻找导入?

但是当它说searching 0 proto paths时,我不禁怀疑......

我的毕业生是:

wire { kotlin { android = true } }

文件结构是

      -> proto
           -> testing
                -> people
                     -> person.proto
                -> tastes
                     -> tastes.proto

我在person.proto 中的导入行是:import "testing/tastes/tastes.proto";

syntax = "proto2";
package testing.people;
option java_package = "com.testing.people";

import "testing/tastes/tastes.proto";

message WirePerson {

    optional string name = 1;
    repeated string picture_urls = 2;
    optional testing.tastes.WirePersonTaste period = 5;
}
syntax = "proto2";
package testing.tastes;
option java_package = "com.testing.tastes";

message WirePersonTaste {
    optional string taste = 1;
    repeated string picture_urls = 2;
}

我将非常感谢任何帮助:)

【问题讨论】:

标签: square-wire


【解决方案1】:

确保原型位于src/main/proto。否则插件不会检测到它。如果移动它有问题,您可以在kotlin {} 配置中将路径指定为选项。

【讨论】:

  • 是的,proto文件的位置没问题,好像我把导入拿出来一样,它可以工作
  • 查看测试项目github.com/Egorand/wire-tastes
  • 这很有趣...我在您的测试项目中遇到了同样的问题。所以它看起来像我的环境?我正在使用 android studio.. @oldergod
  • 更新。我怀疑windows路径有问题。如果我将 Tastes.proto 文件放在 src/main/proto 文件夹而不是 src/main/proto/testing/tastes 文件夹中,我可以让导入工作。我曾尝试在 gradle 选项中将 tastes 目录添加到 protoPath,但是当我这样做时,我得到的只是 Collection contains no element matching the predicat 错误。顺便说一句,使用带有空文件夹位置的 protoPath 似乎是编译的唯一方法(尽管仍然得到 unable to resolve 1 个导入 问题 :( )但随后得到 Cannot find an example of how proto needs to be structure。跨度>
猜你喜欢
  • 1970-01-01
  • 2012-04-04
  • 2013-10-04
  • 1970-01-01
  • 2016-03-12
  • 2018-08-07
  • 2012-11-06
  • 2015-08-04
  • 2015-12-14
相关资源
最近更新 更多