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

Unable to build TDLib for Android #2635

Closed jpage4500 closed 1 year ago

jpage4500 commented 1 year ago

Hi,

I've previously built the TDLib for Android in the past but I can't get it working anymore. I'm following the instructions here: https://github.com/tdlib/td/tree/master/example/android

~/working/external/telegram_sdk/example/android$ ./build-tdlib.sh
Downloading annotation Java package...
Generating TDLib source files...
-- Could NOT find ccache (this is NOT an error)
-- Found OpenSSL: /opt/homebrew/Cellar/openssl@3/3.1.2/include /opt/homebrew/Cellar/openssl@3/3.1.2/lib/libssl.dylib;/opt/homebrew/Cellar/openssl@3/3.1.2/lib/libcrypto.dylib
-- Git state: 986f1ab469b9bbff2b95850cc4485e16798a26b7
-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/usr/lib/libz.tbd
CMake Error at SDK/cmake/3.22.1/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2
  JAVA_AWT_INCLUDE_PATH)
Call Stack (most recent call first):
  SDK/cmake/3.22.1/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  SDK/cmake/3.22.1/share/cmake-3.22/Modules/FindJNI.cmake:382 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /Users/jpage/working/external/telegram_sdk/CMakeLists.txt:930 (find_package)

I should say I'm running on an M1 Mac so maybe that's related to the reason it's failing. If so, does anyone know how to fix?

I also tried running the docker build but that ran for several hours and seemed like it was just re-building over and over without ever actually working.


I'm not using the prebuilt library because it appears it hasn't been updated in a long time.. correct me if I'm wrong there. If it's not going to be maintained can it be removed and the build generator be updated? I'm talking about this:

TDLib for Android is available in a prebuilt form and can be downloaded from there.

levlam commented 1 year ago

CMake Error at SDK/cmake/3.22.1/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)

The script can't find installed system JDK. It can be installed with brew install openjdk or from the official web site. After JDK is installed, you need to add JAVA_HOME environment variable, which should point to the installation path ("/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home/" if JDK is installed with Homebrew).

If it's not going to be maintained can it be removed and the build generator be updated?

Yes, it will be removed after the Android example is completed with all other types of TDLib builds for Android.

jpage4500 commented 1 year ago

@levlam - thanks for the fast reply!

I did install the JDK via brew but noticed JAVA_HOME was set to "/opt/homebrew/opt/openjdk" and not "/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home/"

That seemed to do the trick as it's building now