Phil
Phil

Reputation: 43

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();
}

Upvotes: 1

Views: 7399

Answers (2)

vanguard69
vanguard69

Reputation: 840

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

Upvotes: 1

matt b
matt b

Reputation: 139971

Make sure the code/class/JAR that contains com.google.protobuf.GeneratedMessage is on your classpath when compiling your code.

Upvotes: 0

Related Questions