我试图构建AOSP拉丁IME (源代码:https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/master),而不下载整个AOSP源代码。理想情况下,我希望将该项目构建为一个Gradle项目,这样我就可以轻松地将它与我现有的Android应用程序集成起来。
我已经取得了一些进展
1]在Android中创建一个空白项目
2]复制粘贴"java“和"java-overridable”文件夹,并将"res“文件夹的内容复制粘贴到我的项目中。
但是,当项目编译时,由于以下错误,打开键盘时会崩溃:
无法加载本机库jni_latinime
这个错误是有意义的,因为我还没有构建并包含键盘所需的C++本机库(在这里找到:https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/master/native/jni/)。
如何构建在上述链接中找到的本机库并将其包含在我的Gradle项目中?有没有办法编译这些C++文件而不下载整个AOSP源代码?
该项目附带一个"Android.bp“文件,该文件似乎指定了如何编译C++文件。不幸的是,我不知道如何使用宋楚瑜的构建系统。https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/master/native/jni/Android.bp
发布于 2019-01-30 11:18:15
据我所知,您不能使用soong构建系统,在AOSP tree.so之外用Android.bp编译本机文件,您必须在AOSP树中构建。
但是你能不能只签出一个稳定的分支,而不是使用主分支代码。
Soong is the replacement for the old Android make-based build system.
It replaces Android.mk files with Android.bp files,
which are JSON-like simple declarative descriptions of modules to build.
This Makefile-based system is in the process of being replaced with Soong,
a new build system written in Go.
During the transition, all of these makefiles are read by Kati, and generate a ninja file instead of being executed directly.
That's combined with a ninja file read by Soong so that the build graph of the two systems can be combined and run as one.如果您将代码签出到一个稳定的分支,如饼式发布或奥利奥-r6版本,您将得到源代码而不需要这个soong构建系统,并且您将拥有像Android.mk这样的旧构建系统文件。
但是,如果您仍然需要最新的源代码,您可以读取这个Android.bp文件并创建一个模块本机模块,并使用CMake构建它。
您必须将这个Android.bp文件转换为CMakeLists.txt,以便使用cmake构建它。我认为这不会很困难
Main segement that you want to build is : libjni_latinime
cc_library
{
name: "libjni_latinime",
host_supported: true,
product_specific: true,
sdk_version: "14",
cflags: [
"-Werror",
"-Wall",
"-Wextra",
"-Weffc++",
"-Wformat=2",
"-Wcast-qual",
"-Wcast-align",
"-Wwrite-strings",
"-Wfloat-equal",
"-Wpointer-arith",
"-Winit-self",
"-Wredundant-decls",
"-Woverloaded-virtual",
"-Wsign-promo",
"-Wno-system-headers",
// To suppress compiler warnings for unused variables/functions used for debug features etc.
"-Wno-unused-parameter",
"-Wno-unused-function",
],
local_include_dirs: ["src"],
srcs: [
"com_android_inputmethod_keyboard_ProximityInfo.cpp",
"com_android_inputmethod_latin_BinaryDictionary.cpp",
"com_android_inputmethod_latin_BinaryDictionaryUtils.cpp",
"com_android_inputmethod_latin_DicTraverseSession.cpp",
"jni_common.cpp",
":LATIN_IME_CORE_SRC_FILES",
],
target: {
android_x86: {
// HACK: -mstackrealign is required for x86 builds running on pre-KitKat devices to avoid crashes
// with SSE instructions.
cflags: ["-mstackrealign"],
},
android: {
stl: "libc++_static",
},
host: {
cflags: ["-DHOST_TOOL"],
},
}您必须传递这些CFLAGS并包含dir,源文件列表和目标只需传递android libc++_static,因为其他东西对您没有用处。
如果你想读宋楚瑜的话:https://android.googlesource.com/platform/build/soong/
https://stackoverflow.com/questions/54339029
复制相似问题