Giter Site home page Giter Site logo

generateCommonMainProtos failed with java.lang.NoSuchMethodError: 'void com.squareup.kotlinpoet.NameAllocator.<init>(boolean)' about wire HOT 2 CLOSED

alexvanyo avatar alexvanyo commented on August 28, 2024
generateCommonMainProtos failed with java.lang.NoSuchMethodError: 'void com.squareup.kotlinpoet.NameAllocator.(boolean)'

from wire.

Comments (2)

alexvanyo avatar alexvanyo commented on August 28, 2024 2

Wow, that is annoying...

Running buildEnvironment in the subproject where I'm applying the plugin and the root project doesn't give a kotlinpoet version below 1.16.0, but adding alias(libs.plugins.wire) apply false to the root project's plugins as suggested does indeed fix the issue.

The other plugin I have that brings in kotlinpoet is sqldelight 2.0.1, which depends on kotlinpoet 1.15.2. If I do the opposite, just adding alias(libs.plugins.sqldelight) apply false to the root project, then I see 1.15.2 in the root project's buildEnvironment task.

If I add both, then dependency resolution happens as expected and resolves both to kotlinpoet 1.16.0. I wonder if adding every possible plugin with apply false to the root project is unfortunately the way to avoid this, even if they're only used by a single (or a few) subprojects?

Thank you for the workaround and the explanation, doesn't look like there's anything wire can do here.

from wire.

JakeWharton avatar JakeWharton commented on August 28, 2024 1

wire-kotlin-generator 4.9.6 depends on kotlinpoet-jvm 1.16.0: https://search.maven.org/artifact/com.squareup.wire/wire-kotlin-generator/4.9.6/jar

And kotlinpoet 1.16.0 is the version which added that API: https://github.com/square/kotlinpoet/releases/tag/1.16.0

I didn't try it myself, but I suspect running buildEnvironment will show you something that's forcing your kotlinpoet dependency to an older version. In my experience this happens through the use of the plugins block which has absolutely (and ironically) destroyed the semantics of dependency resolution on the buildscript classpath.

You seem to be applying the plugin only to a single subproject: https://github.com/alexvanyo/composelife/blob/c023f9f9df90b4fbc1013248552623d6f0f07122/preferences-proto/build.gradle.kts#L21

This means that any other plugin which beats that plugin to the buildscript classpath will get its version of KotlinPoet and break Wire. For a quick fix, apply the Wire plugin in the root project with apply false and add another scar to the set of those caused by the plugins block's broken semantics.

from wire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.