semw
semw

Reputation: 147

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 . My application is simple hello world application which I have developed in Android Studio. I have wrote its Android.mk, placed it in 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? or am I missing any steps.

Here is code of my 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)

Upvotes: 2

Views: 1263

Answers (1)

TuanPM
TuanPM

Reputation: 703

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

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. You should check by yourself to ensure these libraries available (usually located in prebuilts directory). In case these libraries not available, you need to download them manually then add them to AOSP build system manually.

Upvotes: 3

Related Questions