Adding prebuilt APK on Lollipop android-5.1.0_r5

2,694 views
Skip to first unread message

Leonardo Aramaki

unread,
May 2, 2015, 9:31:51 AM5/2/15
to android-...@googlegroups.com
Hello. 

I'm working on a clean build from branch android-5.1.0_r5 AOSP. All working fine , successfully built and running on device.
Now I am trying to add prebuilt APKs to the build as follows.

1) I created separate folders for my apps at $ANDROID_BUILD_TOP/packages/apps/

For instance: 
$ANDROID_BUILD_TOP/packages/apps/MyApp

2) Then created inside the new folder, an Android.mk as follows:

LOCAL_MODULE := MyApp
LOCAL_MODULE_OWNER := MyAppOwner
LOCAL_SRC_FILES := MyApp.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_PATH := $(TARGET_OUT)/system/priv-app/MyApp/
LOCAL_CERTIFICATE := platform
include $(BUILD_PREBUILT)

Note: also replaced this 
LOCAL_MODULE_PATH := $(TARGET_OUT)/system/priv-app/MyApp/
with:
LOCAL_MODULE_PATH := $(TARGET_OUT)/system/app/MyApp/

Question: Does the build system needs something different in order for me to assemble the build with my APK inside /system/priv-app directory instead of /system/app ?

3) Copied the referred MyApp.apk to the same folder.

4) Edited my $ANDROID_BUILD_TOP/device/<product>/<target>/aosp_<device>.mk by adding to 
PRODUCT_PACKAGES += \
    ...
    MyApp

5) Issued make systemimage (also tried the whole make -jN). Then the build system worked on the app by making all the necessary compilation ahead and the stopped successfully. Despite of that, no APK was found inside $OUT/system/app/MyApp/ nor $OUT/system/priv-app/MyApp/ in case. Flashed the newly created $OUT/system.img using fastboot with no avail.

What am I missing here?

Regards,

Leonardo Aramaki

unread,
May 2, 2015, 1:41:15 PM5/2/15
to android-...@googlegroups.com
Ok, I was able to make it all build nice and install by changing a few lines at my Android.mk files.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyApp
LOCAL_SRC_FILES := MyApp.apk
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_MODULE_CLASS := APPS
LOCAL_PRIVILEGED_MODULE := true
#LOCAL_MODULE_PATH := $(TARGET_OUT)/system/priv-app/MyApp/
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DEX_PREOPT := false 
include $(BUILD_PREBUILT)

According to the docs, by adding the following line
LOCAL_PRIVILEGED_MODULE := true
the package is installed with privileges under /system/priv-app/ and by removing 
#LOCAL_MODULE_PATH := $(TARGET_OUT)/system/priv-app/MyApp/
the app is installed properly on its location.

The only problem I'm getting now is that the application crashes when the system is up. Inspecting the log, it complains about being unable to find classes.dex inside the apk.
Inside my BoardConfig.mk I have

WITH_DEXPREOPT := true
DONT_DEXPREOPT_PREBUILTS := true

But classes.dex is still getting stripped from the apk. Any hints?

David Hacker

unread,
May 3, 2015, 5:55:34 PM5/3/15
to android-...@googlegroups.com
Are you sure the apk you were using was deodexed and has a classes.dex inside?

Leonardo Aramaki

unread,
May 14, 2015, 11:22:26 PM5/14/15
to android-...@googlegroups.com
Hi David,

Time is tight to test things up. Thank you for taking the time to reply. 
The apk indeed has a classes.dex inside. 
However, I managed to get it right now. In order to get the prebuilt apk with classes.dex into my build I had to put the following on its Android.mk:

LOCAL_DEX_PREOPT := nostripping

It turns out that what I had was supposed to work too (at device.mk):

WITH_DEXPREOPT := true
DONT_DEXPREOPT_PREBUILTS := true

The reason it wasn't working was kinda dummy. I was testing the prebuilt package buiding using 

mmm packages/apps/MyApp/

without first cleaning up $OUT/obj/APPS/MyApp_intermediates/ folder. Or by doing it right with the -B flag set:

mmm packages/apps/MyApp/ -B

Best.

Leonardo Aramaki
----------------------------------------
Bemobi

On Sun, May 3, 2015 at 1:55 PM, David Hacker <dhack...@gmail.com> wrote:
Are you sure the apk you were using was deodexed and has a classes.dex inside?

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages