tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

Can't find field [useDefaultMuteStories] with signature [Z] #2576

Closed adrianbartyczak closed 1 year ago

adrianbartyczak commented 1 year ago

I built a new libtdjni.so library on Debian 12, and I get a new error (which I wasn't getting on Debian 11).

FATAL ERROR in native method: Can't find field [useDefaultMuteStories] with signature [Z] at org.drinkless.tdlib.Client.nativeClientReceive(Native Method) at org.drinkless.tdlib.Client.access$000(Client.java:15) at org.drinkless.tdlib.Client$ResponseReceiver.run(Client.java:148) at java.lang.Thread.run(java.base@11.0.18/Thread.java:829)

Anyone know what this means? (I'm a Java developer, not a C++ developer). Thanks!

levlam commented 1 year ago

It means that you have incompatible versions of libtdjni.so and TdApi.java from different TDLib versions.

adrianbartyczak commented 1 year ago

Oh, I do see the tdlib library in my libs folder. I have it under the name "tdlib-java-src.jar". This is definitely the library that's mismatching.

So when I built the libtdjni.so file, I deleted everything else. I didn't know I was suppose to get the tdlib jar also.

But now when I build Tdlib, I for some reason get the following error:

[ajb@debian:build]$ cmake --build . --target install
[ 20%] Generating Java TDLib API source files
[ 20%] Built target td_generate_java_api
[ 40%] Building Java code
/tmp/td/example/java/org/drinkless/tdlib/example/Example.java:553: error: cannot find symbol
                case TdApi.UpdateChatIsBlocked.CONSTRUCTOR: {
                          ^
  symbol:   variable UpdateChatIsBlocked
  location: class TdApi
/tmp/td/example/java/org/drinkless/tdlib/example/Example.java:554: error: cannot find symbol
                    TdApi.UpdateChatIsBlocked update = (TdApi.UpdateChatIsBlocked) object;
                         ^
  symbol:   class UpdateChatIsBlocked
  location: class TdApi
/tmp/td/example/java/org/drinkless/tdlib/example/Example.java:554: error: cannot find symbol
                    TdApi.UpdateChatIsBlocked update = (TdApi.UpdateChatIsBlocked) object;
                                                             ^
  symbol:   class UpdateChatIsBlocked
  location: class TdApi
/tmp/td/example/java/org/drinkless/tdlib/example/Example.java:557: error: cannot find symbol
                        chat.isBlocked = update.isBlocked;
                            ^
  symbol:   variable isBlocked
  location: variable chat of type Chat
4 errors
gmake[2]: *** [CMakeFiles/build_java.dir/build.make:71: CMakeFiles/build_java] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/build_java.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2

Did something change in the build?

levlam commented 1 year ago

The Java example wasn't updated to the latest TDLib version. I have just pushed a fix for this.

adrianbartyczak commented 1 year ago

That worked. Thanks, but now when I build the Java program, I get a new error:

FATAL ERROR in native method: Can't find field [isBlocked] with signature [Z]
    at org.drinkless.tdlib.Client.nativeClientReceive(Native Method)
    at org.drinkless.tdlib.Client$ResponseReceiver.run(Client.java:148)
    at java.lang.Thread.run(java.base@11.0.18/Thread.java:829)

I'm pretty sure I recreated the tdlib source jar correctly. I noticed all the Java class files are in "tdlib/bin/org/drinkless/tdlib". So I basically packaged them in a jar.

levlam commented 1 year ago

You have libtdjni.so from an old TDLib version. The latest TDLib has no fields named isBlocked.

adrianbartyczak commented 1 year ago

Oh, you were right. I copied it to my projects libs folder, but forgot to copy it to /usr/lib/x86_64-linux-gnu/jni.

You have helped me a lot. Thanks!