Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Fix Example.java to match updated TDLib API#3588

Open
Eronary wants to merge 1 commit intotdlib:masterfrom
Eronary:master
Open

Fix Example.java to match updated TDLib API#3588
Eronary wants to merge 1 commit intotdlib:masterfrom
Eronary:master

Conversation

@Eronary
Copy link

@Eronary Eronary commented Feb 20, 2026

Problem

After recent TDLib API changes, Example.java fails to compile with the following errors:

#32 5.047 [ 40%] Built target generate_javadoc
#32 5.061 [ 60%] Building Java code
#32 5.773 /opt/td/example/java/org/drinkless/tdlib/example/Example.java:292: error: no suitable constructor found for InlineKeyboardButton(String,InlineKeyboardButtonTypeUrl)
#32 5.773         TdApi.InlineKeyboardButton[] row = {new TdApi.InlineKeyboardButton("https://telegram.org?1", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?2", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?3", new TdApi.InlineKeyboardButtonTypeUrl())};
#32 5.773                                             ^
#32 5.773     constructor InlineKeyboardButton.InlineKeyboardButton() is not applicable
#32 5.773       (actual and formal argument lists differ in length)
#32 5.773     constructor InlineKeyboardButton.InlineKeyboardButton(String,long,ButtonStyle,InlineKeyboardButtonType) is not applicable
#32 5.773       (actual and formal argument lists differ in length)
#32 5.775 /opt/td/example/java/org/drinkless/tdlib/example/Example.java:292: error: no suitable constructor found for InlineKeyboardButton(String,InlineKeyboardButtonTypeUrl)
#32 5.775         TdApi.InlineKeyboardButton[] row = {new TdApi.InlineKeyboardButton("https://telegram.org?1", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?2", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?3", new TdApi.InlineKeyboardButtonTypeUrl())};
#32 5.775                                                                                                                                                ^
#32 5.775     constructor InlineKeyboardButton.InlineKeyboardButton() is not applicable
#32 5.775       (actual and formal argument lists differ in length)
#32 5.775     constructor InlineKeyboardButton.InlineKeyboardButton(String,long,ButtonStyle,InlineKeyboardButtonType) is not applicable
#32 5.775       (actual and formal argument lists differ in length)
#32 5.776 /opt/td/example/java/org/drinkless/tdlib/example/Example.java:292: error: no suitable constructor found for InlineKeyboardButton(String,InlineKeyboardButtonTypeUrl)
#32 5.776         TdApi.InlineKeyboardButton[] row = {new TdApi.InlineKeyboardButton("https://telegram.org?1", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?2", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?3", new TdApi.InlineKeyboardButtonTypeUrl())};
#32 5.776                                                                                                                                                                                                                                                   ^
#32 5.776     constructor InlineKeyboardButton.InlineKeyboardButton() is not applicable
#32 5.776       (actual and formal argument lists differ in length)
#32 5.776     constructor InlineKeyboardButton.InlineKeyboardButton(String,long,ButtonStyle,InlineKeyboardButtonType) is not applicable
#32 5.776       (actual and formal argument lists differ in length)
#32 6.140 3 errors
#32 6.194 gmake[2]: *** [CMakeFiles/build_java.dir/build.make:72: CMakeFiles/build_java] Error 1
#32 6.194 gmake[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/build_java.dir/all] Error 2
#32 6.195 gmake: *** [Makefile:136: all] Error 2
#32 ERROR: process "/bin/sh -c cmake -DCMAKE_BUILD_TYPE=Release           -DCMAKE_INSTALL_PREFIX:PATH=/opt/tdlib           -DTd_DIR:PATH=$(readlink -e /opt/td/example/java/td/lib/cmake/Td)           ..  && cmake --build . --target install" did not complete successfully: exit code: 2

Root cause

The InlineKeyboardButton constructor was updated to include new parameters iconCustomEmojiId (long) and style (ButtonStyle), but Example.java was not updated accordingly.

Old signature:

InlineKeyboardButton(String text, InlineKeyboardButtonType type)

New signature:

InlineKeyboardButton(String text, long iconCustomEmojiId, ButtonStyle style, InlineKeyboardButtonType type)

Additionally, InlineKeyboardButtonTypeUrl now requires an explicit url parameter instead of being no-arg:

Old: new InlineKeyboardButtonTypeUrl()
New: new InlineKeyboardButtonTypeUrl(String url)

Similarly, SendMessage constructor gained a new MessageTopic topicId parameter:

Old:

SendMessage(long chatId, InputMessageReplyTo replyTo, MessageSendOptions options, ReplyMarkup replyMarkup, InputMessageContent inputMessageContent)

New:

SendMessage(long chatId, MessageTopic topicId, InputMessageReplyTo replyTo, MessageSendOptions options, ReplyMarkup replyMarkup, InputMessageContent inputMessageContent)

Changes

example/java/org/drinkless/tdlib/example/Example.java — method sendMessage:

  1. InlineKeyboardButton — added 0 for iconCustomEmojiId and null for style (default values, preserving existing behavior).
  2. InlineKeyboardButtonTypeUrl — now passes the URL string explicitly.
  3. SendMessage — added null for the new topicId parameter.

@levlam
Copy link
Contributor

levlam commented Feb 20, 2026

This has already been fixed in the private TDLib version, which will become publicly available with the upcoming Telegram update.

@Eronary
Copy link
Author

Eronary commented Feb 20, 2026

Can we merge these changes now so that the TDLib build passes successfully? When a new version of TDLib is released, my changes will be overwritten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants