首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在树上建立AOSP拉丁文IME?

如何在树上建立AOSP拉丁文IME?
EN

Stack Overflow用户
提问于 2019-01-24 03:37:13
回答 2查看 1.4K关注 0票数 6

我试图构建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

EN

回答 2

Stack Overflow用户

发布于 2019-01-30 11:18:15

据我所知,您不能使用soong构建系统,在AOSP tree.so之外用Android.bp编译本机文件,您必须在AOSP树中构建。

但是你能不能只签出一个稳定的分支,而不是使用主分支代码。

代码语言:javascript
运行
复制
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构建它。我认为这不会很困难

代码语言:javascript
运行
复制
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/

票数 0
EN

Stack Overflow用户

发布于 2019-06-21 13:34:01

科林为LatinIme创建了一个很好的gradle构建。我为我的毕业论文做了一个修改过的拿铁,我真的希望当时有这样一个项目存在。

如果要更改应用程序包名称,还需要相应地更改cpp文件,因为使用这些文件构建的是本机库。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54339029

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档