Protobuf newb

67 views
Skip to first unread message

Geoffrey Schulman

unread,
Jan 3, 2022, 8:14:50 PM1/3/22
to bitcoinj
Curious which version of protobuf I should be building with as 3.19.1 java source has come compilation errors...

Thank you

Geoff Schulman

Andreas Schildbach

unread,
Jan 3, 2022, 8:16:25 PM1/3/22
to bitc...@googlegroups.com
If you use Gradle for building, it should use the correct versions
automatically.

On current master, we use Protobuf 3.18.0.
> --
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bitcoinj+u...@googlegroups.com
> <mailto:bitcoinj+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bitcoinj/34c776d4-b007-47d6-9190-bf05917e8a5dn%40googlegroups.com
> <https://groups.google.com/d/msgid/bitcoinj/34c776d4-b007-47d6-9190-bf05917e8a5dn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Geoffrey Schulman

unread,
Jan 4, 2022, 1:23:35 PM1/4/22
to bitcoinj
Gradle builds just fine, but eclipse complaining about all casts from GeneratedMessageLite.Builder()

    public static Builder newBuilder() {
      return (Builder) DEFAULT_INSTANCE.createBuilder();
    }

Cannot cast from GeneratedMessageLite.Builder<GeneratedMessageLite<GeneratedMessageLite<MessageType,GeneratedMessageLite.Builder<MessageType,BuilderType>>,GeneratedMessageLite.Builder<GeneratedMessageLite<MessageType,BuilderType>,BuilderType>>,GeneratedMessageLite.Builder<GeneratedMessageLite<GeneratedMessageLite<MessageType,BuilderType>,BuilderType>,BuilderType>> to PeerSeedProtos.PeerSeeds.Builder

Geoffrey Schulman

unread,
Jan 4, 2022, 1:26:29 PM1/4/22
to bitcoinj
Found this thread with same issue 


I will try downgrade to protobuf 3.4

Geoffrey Schulman

unread,
Jan 5, 2022, 1:05:09 PM1/5/22
to bitcoinj
Ended up being an issue with java-lite protos in eclipse, amended to used full java 3.18.0 to resolve.  My clean eclipse build notes,

Install JDK 11

Set JAVA_HOME = D:\Java\jdk-11.0.12

Add %JAVA_HOME%\bin to PATH

Install Gradle 4.10.2

        D:\Gradle\gradle-4.10.2

Add Gradle bin to PATH

        D:\Gradle\gradle-4.10.2\bin

Clone latest bitcoinj release

        git clone -b release-0.16 https://github.com/bitcoinj/bitcoinj.git

Ammend core\build.gradle to protobuf-java-3.18.0 (not java-lite) and comment out //option "lite" (https://repo.maven.apache.org/maven2/com/google/protobuf/protobuf-java/)

  api 'com.google.protobuf:protobuf-java:3.18.0'
  ...
  protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.18.0'
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    //option "lite"
                }
            }
        }
    }

Build and create eclipse config in bitcoinj folder

        gradle init
        gradle clean assemble
        gradle eclipse

Install eclipse-java-2020-06-R-win32-x86_64

        File > Import > General > Existing Projects into Workspace > <bitcoinj folder>

        Change file encoding to UTF8 /bitcoinj-core/src/test/java/org/bitcoinj/utils/BtcFormatTest.java

        Run /bitcoinj-tools/src/main/java/org/bitcoinj/tools/WatchMempool.java

Geoffrey Schulman

unread,
Jan 5, 2022, 9:48:00 PM1/5/22
to bitcoinj
Gradle builds core just fine, maybe an issue with eclipse giving the following protobuf casting error?  Is there a recommended eclipse version?

Thank you

Geoff Schulman

eclipse protobuf casting error.jpg


On Monday, January 3, 2022 at 8:16:25 PM UTC-5 Andreas Schildbach wrote:
Reply all
Reply to author
Forward
0 new messages