简体   繁体   English

在 AOSP 源代码中添加系统应用程序(通过 App 源代码/工作 AS 项目)

[英]Add System application(Through App source code/working AS project) in AOSP source code

I am trying to add an application in AOSP source through app source code, not by apk .我正在尝试通过 app 源代码而不是 apk 在 AOSP 源中添加应用程序。 My application is simple hello world application which I have developed in Android Studio.我的应用程序是我在 Android Studio 中开发的简单 hello world 应用程序。 I have wrote its Android.mk , placed it in packages/app/myapplication/Android.mk .我写了它的Android.mk ,把它放在packages/app/myapplication/Android.mk Registered application package name in aosp_source_code/build/target/product/handheld_system.mk Did I make any mistakes in Android.mk file?aosp_source_code/build/target/product/handheld_system.mk注册的应用程序包名称我在Android.mk文件中aosp_source_code/build/target/product/handheld_system.mk误吗? or am I missing any steps.或者我错过了任何步骤。

Here is code of my Android.mk这是我的Android.mk代码

include $(CLEAR_VARS)

LOCAL_PACKAGE_NAME := Myapplication
LOCAL_MODULE_TAGS := optional
LOCAL_PRIVILEGED_MODULE := true
LOCAL_CERTIFICATE := platform

LOCAL_PRIVATE_PLATFORM_APIS := true

LOCAL_SRC_FILES := $(call all-java-files-under, src/main/java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/src/main/res
LOCAL_MANIFEST_FILE := src/main/AndroidManifest.xml

LOCAL_DEX_PREOPT := false
LOCAL_PROGUARD_ENABLED := disabled

LOCAL_USE_AAPT2 := true

LOCAL_STATIC_ANDROID_LIBRARIES := \
    android-arch-lifecycle-extensions \
    android-support-v7-recyclerview \
    android-support-v7-appcompat \
    android-support-constraint-layout
include $(BUILD_PACKAGE) 

Errors错误

packages/apps/Myapplication/src/main/res/layout/content_main.xml:8: error: attribute defaultNavHost (aka com.myapplication:defaultNavHost) not found.
packages/apps/Myapplication/src/main/res/layout/content_main.xml:8: error: attribute navGraph (aka com.myapplication:navGraph) not found.
packages/apps/Myapplication/src/main/res/navigation/nav_graph.xml:2: error: attribute startDestination (aka com.myapplication:startDestination) not found.
packages/apps/Myapplication/src/main/res/navigation/nav_graph.xml:14: error: attribute destination (aka com.myapplication:destination) not found.
packages/apps/Myapplication/src/main/res/navigation/nav_graph.xml:24: error: attribute destination (aka com.myapplication:destination) not found.
error: failed linking file resources.
11:57:34 ninja failed with: exit status 1

#### failed to build some targets (4 seconds)

As i saw on your build.gradle file, you probably need to link androidx.appcompat:appcompat , androidx.constraintlayout:constraintlayout , androidx.navigation:navigation-ui and androidx.navigation:navigation-fragment in your Android.mk正如我在您的 build.gradle 文件中看到的,您可能需要在您的 Android.mk 中链接androidx.appcompat:appcompatandroidx.constraintlayout:constraintlayoutandroidx.navigation:navigation-uiandroidx.navigation:navigation-fragment

Example例子

LOCAL_STATIC_ANDROID_LIBRARIES := \
    androidx.appcompat_appcompat \
    androidx-constraintlayout_constraintlayout \
    androidx-navigation_navigation-ui \
    androidx-navigation_navigation-fragment \
    ...

But androidx-navigation_navigation-ui and androidx-navigation_navigation-fragment may available or not available depend on your AOSP build system.但是androidx-navigation_navigation-uiandroidx-navigation_navigation-fragment可能可用或不可用取决于您的 AOSP 构建系统。 You should check by yourself to ensure these libraries available (usually located in prebuilts directory).您应该自己检查以确保这些库可用(通常位于prebuilts目录中)。 In case these libraries not available, you need to download them manually then add them to AOSP build system manually.如果这些库不可用,您需要手动下载它们,然后手动将它们添加到 AOSP 构建系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM