-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build error: Bult Android binaries do not load #840
Comments
Thank you for the report. I think your analysis is right. Seems that trying to build only *.so files with Today I played with the other approach, which is also explained in another section in the same page, to follow the way people build an APK with native libraries with Bazel in an end to end manner. This approach, which builds an APK with So my plan is to rewrite the current build rule with the above one. It still takes time for me to finish cleaning up my prototype before submitting it, but I'm mostly sure that this is at least a fixable problem. I'll update this thread when the fix becomes ready. |
Thank you so much for the detailed and quick response! I'm not well versed in the Android NDK world, especially when building with bazel, so it would have taken me ages to figure this out. I really appreciate it. |
With b0a604f, loading
Can you confirm that Here is a copy of native_libs.zip downloaded from https://github.com/google/mozc/actions/runs/6727110559 |
It loads perfectly now. Thank you so much! |
Typing quality * Updated the word dictionary. * Adjusted the conversion with suffix numbers (e.g. 後に vs あと2). Windows * Prelaunch processes from the installer (#845) Build * Updated the Protobuf version: v24.2 → v25.0 (#841) * Updated the Abseil version: 20230125.3 → 20230802.1 (#841) * Supported to follow updates of external environmental dependencies (#843, #844) * Removed `third_party/ipa_font` and introduced our own testing font (#842) * Android: Fixed the linkage error of Android library build (#840) PiperOrigin-RevId: 582509744
This is a follow up to my previous commit [1], which aimed to build 'libmozc.so' for relevant architectures. Although in the above commit I believe I followed exactly the same step explained in the Bazel document [2], it seems that artifact files are not ready to run on the actual Android devices. Perhaps it might be because the above approach is for those who want to build native libraries for Android without building an APK, which is somewhat not-a-major use case and may not be well maintained. This is why I ended up building a temporary fat APK only to extract native libraries from it. Basically what this commit does are: 1. Build a fat APK, which depends on 'mozcjni' cc_library target. 2. Extract native libraries from the APK and zip it as native_libs.zip The temporary APK used here is completely empty and used only for building purpose. The 'package' meta target is updated to point to the native library build target, which is 'android/jni:native_libs'. bazel build --config oss_android package ls bazel-bin/android/jni/native_libs.zip '.bazelrc' is also updated because Android build starts using the following options instead. * --android_crosstool_top=@androidndk//:toolchain * --fat_apk_cpu=armeabi-v7a,arm64-v8a,x86,x86_64 Dockerfile is also updated because now Android build requires not only Android NDK but also Android SDK. This commit only affects Android build target. Other build target should continue to success without installing Android SDK/NDK. Closes google#840. [1]: 5a6e457 [2]: https://bazel.build/docs/android-ndk#cclibrary-android [3]: https://bazel.build/docs/android-ndk PiperOrigin-RevId: 578420951
Typing quality * Updated the word dictionary. * Adjusted the conversion with suffix numbers (e.g. 後に vs あと2). Windows * Prelaunch processes from the installer (google#845) Build * Updated the Protobuf version: v24.2 → v25.0 (google#841) * Updated the Abseil version: 20230125.3 → 20230802.1 (google#841) * Supported to follow updates of external environmental dependencies (google#843, google#844) * Removed `third_party/ipa_font` and introduced our own testing font (google#842) * Android: Fixed the linkage error of Android library build (google#840) PiperOrigin-RevId: 582509744
Description
This problem happens both when building libmozcjni.so via the Docker build instructions and when using one of the github CI build artifacts. The generated libmozcjni.so contains a great deal of undefined function references but no links to any libraries which define those functions. The result is that attempting to load this library on Android results in an error when calling
System.loadLibrary()
.Commit-id
006084c (latest)
Build target
Choose one of them
1. Docker build for Linux and Android-lib
CI build status
Whether the current CI build status is
passing
orfailure
.https://github.com/google/mozc#build-status
Choose either of them
Environment
Docker image built from latest revision
Build commands
Following exactly https://github.com/google/mozc/blob/master/docs/build_mozc_in_docker.md.
Error logs
Here is the dlopen error generated from attempting to call loadLibrary on the latest CI artifact.
Additional context
Here is the output of
objdump -T
on the latest CI artifact for Android. (Only the relevant lines are included.)A good number of these appear to be libc++ functions. However, libmozcjni.so doesn't link to libc++ according to
readelf -d
.I may be making a mistake and misunderstanding how elf/Android works, but something here seems wrong to me.
The text was updated successfully, but these errors were encountered: