java - Protobuf: UninitializedMessageException is thrown but isInitialized() returns true -


i'm experimenting bit protobuf in android , i'm bit stuck. i'm trying create message com.google.protobuf.uninitializedmessageexception: message missing required fields. however, isinitialized() returns true , i'm using optional & repeated fields.

i'm sure i'm missing something. ideas?

here proto file:

package mobile_app;  message msg {   enum command {     login = 0;     logout = 1;   }    message param {     optional int32 param_id = 1;     repeated string items = 2;   }   enum errorcode {     login_ok = 0;     login_failed = 1;     unknown_param_id = 2;   }   optional command command = 1;   optional int32 param_id = 2;   optional errorcode error_code = 3;   optional string username = 4;   optional string password = 5;   repeated param params = 6; } 

and code:

// ... messages.msg.builder loginmessage = messages.msg.newbuilder(); loginmessage.setcommand(messages.msg.command.login)     .setusername(username)     .setpassword(password);  boolean isok = loginmessage.isinitialized();  // returns true messages.msg m = loginmessage.build();  // throws exception // ... 

i tried code on pure java application , works fine. seems it's android specific problem.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -