Git Product home page Git Product logo

Comments (25)

hiBrianLee avatar hiBrianLee commented on April 28, 2024

I am also seeing this when using snapshot:
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'

Maybe related to google/auto@e02e2a8?

from dagger.

hiBrianLee avatar hiBrianLee commented on April 28, 2024

Yeah seems like asTypeElements method changed - google/auto@e02e2a8#diff-117761445d686cc88f0b75d965af5a1aL466

from dagger.

hiBrianLee avatar hiBrianLee commented on April 28, 2024

What's the correct way to set up gradle to use the jar files to avoid SNAPSHOT issues like this?

I've tried

apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    compile files('libs/dagger-2.0-20150122.022617-13.jar');
    apt files('libs/dagger-compiler-2.0-20150122.022637-13.jar');
    compile 'javax.inject:javax.inject:1'
    provided 'javax.annotation:javax.annotation-api:1.2'
}

but it doesn't seem to be working. It compiles without error but it force closes when I run the app (Caused by: java.lang.ClassNotFoundException: Didn't find class "com.abc.CustomApplication" on path: DexPathList), and intelliJ also doesn't seem be able to find Dagger_AppComponent.builder() that's reference in the CustomApplication file. I didn't see these issues when using SNAPSHOT from maven directly, and would like to know how to use the JAR files directly.

from dagger.

JakeWharton avatar JakeWharton commented on April 28, 2024

You haven't included the dependencies of the dagger-compiler on the apt classpath.

from dagger.

hiBrianLee avatar hiBrianLee commented on April 28, 2024

Thanks. Adding the following based on the pom.xml file worked (to use the dagger-compiler jar, sort of)

    apt files('libs/dagger-producers-2.0-20150122.022620-1.jar');
    apt 'com.google.auto:auto-common:1.0-SNAPSHOT'
    apt 'com.squareup:javawriter:2.5.0'
    apt 'com.google.guava:guava:18.0'

However, since dagger-compiler depends on the snapshot version of auto-common anyway, back to square one I guess!

For others running into this NoSuchMethodError issue, you can (temporarily) include the previous auto-common snapshot from https://oss.sonatype.org/content/repositories/snapshots/com/google/auto/auto-common/1.0-SNAPSHOT/ as a work around.

    compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
    apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
    provided 'javax.annotation:javax.annotation-api:1.2'
    apt files('libs/auto-common-1.0-20150122.001631-7.jar');
    apt 'com.google.guava:guava:18.0'

from dagger.

artem-zinnatullin avatar artem-zinnatullin commented on April 28, 2024

Damn, this is bad, one snapshot library depends on another snapshot library.. Callback snapshot hell.

What about semantic versioning and/or fixed inner dependencies? I don't want to talk about #109, but inner snapshot dependencies — serious problem for production

from dagger.

JakeWharton avatar JakeWharton commented on April 28, 2024

Ugh, please no. A shaded compiler jar is all that's needed.

from dagger.

artem-zinnatullin avatar artem-zinnatullin commented on April 28, 2024

Downloading jars... Interesting, how many developers are currently thinking "WTF with my build?" :)

from dagger.

rapropos avatar rapropos commented on April 28, 2024

To expand a bit on the workaround, you need to download and reference three separate jars, temporarily replacing the dagger-compiler dependency with the following:

apt files('libs/dagger-producers-2.0-20150122.022620-1.jar')
apt files('libs/dagger-compiler-2.0-20150122.022637-13.jar')
apt files('libs/auto-common-1.0-20150122.001631-7.jar')
apt 'com.squareup:javawriter:2.5.0'
apt 'com.google.guava:guava:18.0'

from dagger.

vishna avatar vishna commented on April 28, 2024

With the above workaround I was running into java.lang.ClassNotFoundException in android runtime so I did the following:

apt ('com.google.dagger:dagger-compiler:2.0-SNAPSHOT') {
        exclude group: 'com.google.auto'
}
apt files('libs/auto-common-1.0-20150122.001631-7.jar')

so that requites only one jar instead of three, hopefully this gets fixed soon

from dagger.

mgrzechocinski avatar mgrzechocinski commented on April 28, 2024

IMHO it might be done easier, since fortunately dagger-compiler has it's jar-with-dependencies variant (download it).

Here's how I changed my build.gradle:

-   compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
+   compile files('libs/dagger-2.0-20150122.022617-13.jar');
+   compile 'javax.inject:javax.inject:1' //transient dependency of Dagger core

-   apt "com.google.dagger:dagger-compiler:2.0-SNAPSHOT"
+   apt files('libs/dagger-compiler-2.0-20150122.022637-13-jar-with-dependencies.jar');

Actually, this is madness (#109). But it works.

from dagger.

confile avatar confile commented on April 28, 2024

+1 I have the same problem.

from dagger.

koalahamlet avatar koalahamlet commented on April 28, 2024

I was seeing this error earlier as well. Just out of interest, was that causing peoples Dagger_{whatever}Component to not be compiled correctly?

from dagger.

cgruber avatar cgruber commented on April 28, 2024

I am in the process of exporting a new update - this was the syncs getting out of sync, and I"ll fix. I'm also going to be jarjar-ing the binary so when we publish a snapshot (or release) it'll be resistent to dependency version skew.

from dagger.

cbeust avatar cbeust commented on April 28, 2024

👍

from dagger.

chrisjenx avatar chrisjenx commented on April 28, 2024

Thanks @cgruber!

from dagger.

sbuettner avatar sbuettner commented on April 28, 2024

Thank you for looking into this.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

PR #115 fixes this. Should merge shortly.

from dagger.

cgruber avatar cgruber commented on April 28, 2024

So - apologies for all of this. Having seen these interactions, I'm going to do a little work on my end to keep us from dealing with this sort of skew. But the new version should be out, and it should work.

from dagger.

artem-zinnatullin avatar artem-zinnatullin commented on April 28, 2024

@cgruber it's okay for alpha-beta-whatever-snapshot, at least, Dagger didn't delete /usr/ folder 👍

from dagger.

kboyarshinov avatar kboyarshinov commented on April 28, 2024

Thanks! 👍

from dagger.

ksidpen avatar ksidpen commented on April 28, 2024

Appreciated

from dagger.

damianpetla avatar damianpetla commented on April 28, 2024

It's alive again! Thanks @cgruber !

from dagger.

pakoito avatar pakoito commented on April 28, 2024

👍 💯

from dagger.

chrisjenx avatar chrisjenx commented on April 28, 2024

I'll close this now. As this is working with the latest snapshot. Thanks @cgruber (and co).

from dagger.

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.