rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.77k stars 1.22k forks source link

Guice 4.2.2 and Guava version conflict #595

Open snejokeee opened 5 years ago

snejokeee commented 5 years ago

When i use dependency like this:

        <dependency>
            <groupId>org.telegram</groupId>
            <artifactId>telegrambots-abilities</artifactId>
            <version>4.1.2</version>
        </dependency>

I get this error: Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V at com.google.inject.TypeLiteral.getParameterTypes(TypeLiteral.java:278) at com.google.inject.spi.InjectionPoint.forMember(InjectionPoint.java:115) at com.google.inject.spi.InjectionPoint.<init>(InjectionPoint.java:82) at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:274) at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:115) at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:706) at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:930) at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:852) at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:291) at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:222) at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:938) at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:48) at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:60) at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133) at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) at com.google.inject.Guice.createInjector(Guice.java:87) at com.google.inject.Guice.createInjector(Guice.java:69) at com.google.inject.Guice.createInjector(Guice.java:59) at org.telegram.telegrambots.meta.ApiContext.getInjector(ApiContext.java:46) at org.telegram.telegrambots.meta.ApiContext.getInstance(ApiContext.java:25)

I found 2 solutions:

  1. Use version 4.1 insteed of 4.1.2
  2. change pom.xml like this:
       <dependency>
            <groupId>org.telegram</groupId>
            <artifactId>telegrambots-abilities</artifactId>
            <version>4.1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>com.google.guava</groupId>
                    <artifactId>guava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>27.1-jre</version>
        </dependency>

    And its works for me.

botuser52 commented 5 years ago

I am still getting the error with TelegramBot Api 4.3 released 03 Jun 2019. I tried changing all guava 25.1 to 27.1 but still it did not work. @rubenlagus Can you please check asap?

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V at com.google.inject.TypeLiteral.getParameterTypes(TypeLiteral.java:278) at com.google.inject.spi.InjectionPoint.forMember(InjectionPoint.java:115) at com.google.inject.spi.InjectionPoint.(InjectionPoint.java:82) at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:274) at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:115) at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:706) at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:930) at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:852) at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:291) at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:222) at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:938) at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:48) at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:60) at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133) at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) at com.google.inject.Guice.createInjector(Guice.java:87) at com.google.inject.Guice.createInjector(Guice.java:69) at com.google.inject.Guice.createInjector(Guice.java:59) at org.telegram.telegrambots.meta.ApiContext.getInjector(ApiContext.java:46) at org.telegram.telegrambots.meta.ApiContext.getInstance(ApiContext.java:25) at org.telegram.telegrambots.bots.TelegramLongPollingBot.(TelegramLongPollingBot.java:16) at bot.BarmajiBot.(BarmajiBot.java:32) at bot.BarmajiMain.main(BarmajiMain.java:55)

My changed files telegrambots-meta/pom.xml pom.xml.txt Bots.ipr.txt

HazMux commented 4 years ago

Same prolem( Dependencies compile('org.telegram:telegrambots:4.8.1') compile group: 'com.google.guava', name: 'guava', version: '25.0-cuba.0'