B4A Library Telegram Bots API

Dave61

Member
Licensed User
Longtime User
I am having trouble getting this to work.

If I add the lSMMTeleBot library I get the following error regarding missing java-telegram-bot-api-full.jar file so I added that.
I then had to add okhttp-3.3.1.jar which it also complains about.
Then, recompiling my app, without any new code added - I get the following error:

Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Address;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Authenticator;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Authenticator$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Cache;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Cache$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Cache$2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Cache$CacheRequestImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Cache$CacheRequestImpl$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lokhttp3/Cache$CacheResponseBody;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:696)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
at com.android.dx.command.dexer.Main.runDx(Main.java:293)
at com.android.dx.command.dexer.Main.main(Main.java:249)
at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:688)

I would definitely like to add in Telegram messages to my app. Don't suppose anyone knows the solution or another Telegram library?
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Did you reference okhttp library ?
 

Dave61

Member
Licensed User
Longtime User
Ah, I think that answer led me to the problem - I already had another version of okhttp in my library folder.

And now I suspect my okhttp 3.3.1.jar that I downloaded might not work as there was no .xml file with it.
Looks like I need to search for the necessary .jar & .xml file somewhere...
 

DonManfred

Expert
Licensed User
Longtime User
And now I suspect my okhttp 3.3.1.jar that I downloaded might not work as there was no .xml file with it.
Looks like I need to search for the necessary .jar & .xml file somewhere...
sounds like the wrong solution. There are no such files.

Correct is to use okhttputils. Do not reference another okhttp.jar
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
No , okhttp jar has no xml

sounds like the wrong solution. There are no such files.

Correct is to use okhttputils. Do not reference another okhttp.jar
I think it was my fault , this library needs okhttp jar but I believe it did not work with the standard one (B4A's one )
I should have make it an #AdditionalJar instead of @DependsOn
 

Dave61

Member
Licensed User
Longtime User
I might have to give up on this.
I have okhttputils library ticked and still get the same error as above.
I tried with and without the okhttp library ticked but it makes so difference - still the same error.
 

pompierecattivo

Member
Licensed User
Longtime User
Hello,
io still use this old thread because i think my problem is strictly joined (but i can start a new one, of course)
I cannot run this library because there is a stop searching google json (gson) jar library
The first line of debug is:

B4X:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/Gson;

I have two version of gson library (gson-2.8.5.jar and gson-2.8.6.jar) on both lib folders, external and internal.

Any idea or help appreciate, thank you.
 

pompierecattivo

Member
Licensed User
Longtime User
This is a problem. You should never put additional jars into the internal libraryfolder unless you are told to put them there.

Thanks for quick answer.

I've paste jar on internal folder cause 'end of ideas'....

Ok. I've removed all unecessary. Actually only gson-2.8.5.jar (installed with my version ov b4a) is on internal library folder. This ismy starting point, of course i still receive error compiling code.
The use of ' #AdditionalJar' (on the manifest, i suppose) you suggest is just if i want include some library. But this case .jar is on internal lib folder...
 

pompierecattivo

Member
Licensed User
Longtime User
...to be more precise....
the error i post before is the first one happen, immediately followed by:

B4X:
java.lang.reflect.InvocationTargetException

happen on the line who call the library

B4X:
    gram.Initialize( "1000000000:yyyyyyyyyyyyyyyyyyyA","telegramma",5000,5000,5000)

I suppose this secon one is strictly related to the first...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…