简体   繁体   中英

com.google cannot be resolved to a type

I am trying to to work with protocol buffers for my first time. I have been following the steps in the code below (this is for an android application): http://www.ibm.com/developerworks/xml/library/x-dataAndroid/?ca=drs-#resources However, I cannot seem to get it to work. Since my own coding didn't work, I decided to try and use the source code provided... well this is when I run into the problem that I was having with my own code. I get.. "com.google cannot be resolved to a type" for situations like the one below. Please help! I have been stuck trying to get this protocol buffer sample to work for days now. Thanks!

 public static final class Quote extends
  com.google.protobuf.GeneratedMessage {
// Use Quote.newBuilder() to construct.
private Quote() {
  initFields();
}

Well this answer is for a situation related to something like this.

Please make sure that the version of protobuf runtime's dependency that you add to your project is exactly same as that of the compiler that you installed.

In my case as I was using maven, so I used the following dependency for compiler version -3.0.0

<dependency>
    <groupId>com.google.protobuf</groupId>
    <artifactId>protobuf-java</artifactId>
    <version>3.0.0</version>
</dependency>

To read about compiler installation you can refer: https://github.com/google/protobuf/blob/master/src/README.md

编译代码时,请确保包含com.google.protobuf.GeneratedMessage的代码/类/ JAR位于您的类路径中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM