Adding prebuilt APK fails

7,030 views
Skip to first unread message

Tiago Vieira

unread,
Jun 4, 2010, 3:19:17 PM6/4/10
to android-...@googlegroups.com
Hi everyone, it's my first email to this group.

I'm building Android from source. I'm using all applications already in generic.mk and product.mk within the build folder. I'm also adding some prebuilt APKs following the Prebuilt cookbook on the Open Source website.

One example is Facebook. I extracted the Facebook.apk from the Marketplace. If I install this app through 'adb install' it works ok. But when I build with this apk added into the build, it doesn't work. I've done the samething for Twitter and it worked fine.

This is a piece of the logcat:

W/PackageManager( 89): Exception reading apk: /system/app/AndroidFacebook.apk
W/PackageManager( 89): java.io.IOException: /system/app/AndroidFacebook.apk
W/PackageManager( 89): at dalvik.system.DexFile.isDexOptNeeded(Native Method)
W/PackageManager( 89): at com.android.server.PackageManagerService.performDexOptLI(PackageManagerService.java:2153)
W/PackageManager( 89): at com.android.server.PackageManagerService.performDexOpt(PackageManagerService.java:2139)
W/PackageManager( 89): at com.android.server.am.ActivityManagerService.ensurePackageDexOpt(ActivityManagerService.java:1750)
W/PackageManager( 89): at com.android.server.am.ActivityManagerService.generateApplicationProvidersLocked(ActivityManagerService.java:7818)
W/PackageManager( 89): at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:5513)
W/PackageManager( 89): at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:5673)
W/PackageManager( 89): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:311)
W/PackageManager( 89): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1552)
W/PackageManager( 89): at android.os.Binder.execTransact(Binder.java:287)
W/PackageManager( 89): at dalvik.system.NativeStart.run(Native Method)


Any idea why the app doesn't work when I add a prebuilt APK into the build but it works ok when I install via adb?

Thanks in advance,

Tiago

FrankG

unread,
Jun 7, 2010, 3:59:55 AM6/7/10
to android-platform
Hi Tiago,

I don't know the Prebuilt cookbook ( can you give me a pointer ?),
so I have no idea how you Build-File looks like.

Nevertheless I have good success with kind of Android.mk File :

LOCAL_MODULE := <YourAppName>
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)

include $(BUILD_PREBUILT)

The special thing is IMHO the "include $(BUILD_PREBUILT)".

Good luck !

Frank




On 4 Jun., 21:19, Tiago Vieira <ti...@tvieira.com> wrote:
> Hi everyone, it's my first email to this group.
>
> I'm building Android from source. I'm using all applications already in generic.mk and product.mk within the build folder. I'm also adding some prebuilt APKs following the Prebuilt cookbook on the Open Source website.
>
> One example is Facebook. I extracted the Facebook.apk from the Marketplace. If I install this app through 'adb install' it works ok. But when I build with this apk added into the build, it doesn't work. I've done the samething for Twitter and it worked fine.
>
> This is a piece of the logcat:
>
> W/PackageManager(   89): Exception reading apk: /system/app/AndroidFacebook.apk
> W/PackageManager(   89): java.io.IOException: /system/app/AndroidFacebook.apk
> W/PackageManager(   89):        at dalvik.system.DexFile.isDexOptNeeded(Native Method)
> W/PackageManager(   89):        at com.android.server.PackageManagerService.performDexOptLI(PackageManagerServ­ice.java:2153)
> W/PackageManager(   89):        at com.android.server.PackageManagerService.performDexOpt(PackageManagerServic­e.java:2139)
> W/PackageManager(   89):        at com.android.server.am.ActivityManagerService.ensurePackageDexOpt(ActivityMa­nagerService.java:1750)
> W/PackageManager(   89):        at com.android.server.am.ActivityManagerService.generateApplicationProvidersLo­cked(ActivityManagerService.java:7818)
> W/PackageManager(   89):        at com.android.server.am.ActivityManagerService.attachApplicationLocked(Activi­tyManagerService.java:5513)
> W/PackageManager(   89):        at com.android.server.am.ActivityManagerService.attachApplication(ActivityMana­gerService.java:5673)
> W/PackageManager(   89):        at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:311­)
> W/PackageManager(   89):        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerServ­ice.java:1552)

nguyenvuthiennga

unread,
Jun 8, 2010, 3:47:57 AM6/8/10
to android-platform
Hi,

I also tried to add pre-built apk. I follows the instructions from
this link

http://source.android.com/porting/build_cookbook.html

Compiling gives no error but I don't see my package in installed-
files.txt as well as in the launcher.

Does anyone have a hint?

Thanks in advance,

Nga

FrankG

unread,
Jun 8, 2010, 3:59:50 AM6/8/10
to android-platform
I assume that in your case it is the missing entry
in app/mydroid/build/target/product/generic.mk

Good luck !

Frank
> > > Tiago- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Pavan Savoy

unread,
Jun 8, 2010, 5:21:37 AM6/8/10
to android-...@googlegroups.com
Wonder why the "mm" command installs the .apk but not the top level
make -j2 command.
Is there a vendor specific file - where I can mention the same ? i.e
list of apps to be installed like the build/target/product/core.mk ?

> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.
> To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.
>
>

--
--Pavan Savoy

nguyenvuthiennga

unread,
Jun 8, 2010, 8:08:25 AM6/8/10
to android-platform
Hi Frank,

Actually, I added the entry in vendor/aosp/products/aosp_core.mk

I did the same with my applications and it works.

Is there difference between mk files in build/target/product and
vendor/aosp/products?

Nga

FrankG

unread,
Jun 8, 2010, 9:16:40 AM6/8/10
to android-platform
Hello Nga,

I don't know. I simply saw that the other vendor extensions APKs from
app/mydroid/vendor also put into generic.mk.

Good luck !

Frank
> > --Pavan Savoy- Zitierten Text ausblenden -

Tiago Vieira

unread,
Jun 21, 2010, 11:35:23 AM6/21/10
to android-...@googlegroups.com
Hi all

I solved the problem. When I install an APK via adb, the process extracts the libraries from the APK and copy it to some folder which is visible by the application itself.

The problem was when I add an APK through the prebuilt process, the .so library needed by the app was not being extracted (actually there is no "installation process", it is just copying files across) .

What I've done was finding through the logcat what .so was extracted for the particular APK during adb installation. Then I pull the file out from the handset and add into the Android.mk like:

include $(CLEAR_VARS)
LOCAL_MODULE := lib.so
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
LOCAL_SRC_FILES := libs/$(LOCAL_MODULE)
OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
include $(BUILD_PREBUILT)

That library is now going into a shared place and the application starts correctly. I had to do that for 3 or 4 APK I've been built as preloaded app.

I wouldn't change any file within the build directory as it can be overwritten in a future release and you are going to have lots of headaches in a future. Keep your changes within vendor directory as per Google's documentation on the PDK website.

Regards,
Tiago

FrankG

unread,
Jun 22, 2010, 9:41:48 AM6/22/10
to android-platform
Hello Tiago,

thanks for your update.

But your original stacktrace is strange and misleading. I think nearly
everyone who add a prebuild app with some ndk stuff know this problem,
but normaly the error
indicates that the app is searching under /system/lib for his shared
library. But I your case their was no indication for this ?

Nevertheless nice if is solved know for you.

Best regards !

Frank
> > For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.- Zitierten Text ausblenden -

Tiago Vieira

unread,
Jun 22, 2010, 9:55:59 AM6/22/10
to android-...@googlegroups.com
Hi Frank

When I installed those apks via adb I found their libraries in /data/data/<packagename>/lib folder.

This looks a place where the apk shares libraries to itself. That would be OK if the library goes to that place during a prebuilt, which is not the case. The library just doesn't come out of the apk.
So, adding the extracted library into the shared libraries folder worked (and, yes, I think that is a bit dirty way to do this... :-) ).

I'm new to the Android build system, so that was the way it was solved for the moment. But, it would be good to know what would be the best practice in this case. It is difficult to find more information about the Android Build System apart from what the PDK site has.

Best regards,

Tiago

FrankG

unread,
Jun 23, 2010, 10:57:18 AM6/23/10
to android-platform
Hello Tiage,

I have a simliar makefile ( without OVERRIDE_BUILT_MODULE_PATH := $
(TARGET_OUT_INTERMEDIATE_LIBRARIES) )
and with them the Shared Libraries are put in the generated system
image under /system/lib.

Good luck !

Frank
> >>> For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.-Zitierten Text ausblenden -

Dianne Hackborn

unread,
Jun 23, 2010, 12:42:23 PM6/23/10
to android-...@googlegroups.com
The mm and mmm commands are short-cuts for use during rapid iteration of development to build specific targets without doing the full dependency tracking or product resolution.  They thus can behave is slightly different ways from a regular make.
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

dev.c...@gmail.com

unread,
Jul 10, 2017, 10:27:25 AM7/10/17
to android-platform, ti...@tvieira.com
Hi all,

 I am still facing this problem. Can any one tell me where to place these libraries means in which folder of aosp.

dev.c...@gmail.com

unread,
Jul 13, 2017, 10:48:18 AM7/13/17
to android-platform, ti...@tvieira.com
After Copying lib files at required location . My app is able to find but now Permission Issue. 

java.lang.UnsatisfiedLinkError: dlopen failed: can't protect segments for "/system/app/XYZ/lib/arm/libtmfbeng.so": Permission denied
                                                       at java.lang.Runtime.loadLibrary0(Runtime.java:989)
                                                       at java.lang.System.loadLibrary(System.java:1562)
                                                       at com.trendmicro.virdroid.feedback.FeedbackEngine.<clinit>(Unknown Source)
                                                       at com.trendmicro.virdroid.service.SafeMobileService.a(Unknown Source)
                                                       at com.trendmicro.virdroid.service.SafeMobileService.onStartCommand(Unknown Source)
                                                       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3327)
                                                       at android.app.ActivityThread.-w

毛Türkçe

unread,
Jul 16, 2020, 11:05:52 AM7/16/20
to android-platform
What about 64 bit build?  Do I have to put both x86 & x86_64 binaries to the image, if so how to write the makefile?

在 2010年6月21日星期一 UTC+8下午11:35:23,Tiago Vieira写道:

>>>> To unsubscribe from this group, send email to android-...@googlegroups.com.


>>>> For more options, visit this group athttp://groups.google.com/group/android-platform?hl=en.
>>
>>> --
>>> --Pavan Savoy- Zitierten Text ausblenden -
>>
>> - Zitierten Text anzeigen -
>
> --
> You received this message because you are subscribed to the Google Groups "android-platform" group.
> To post to this group, send email to android-...@googlegroups.com.

> To unsubscribe from this group, send email to android-...@googlegroups.com.

Mudassar Waheed

unread,
Sep 21, 2020, 10:39:37 AM9/21/20
to android-platform
Hi @Tiago Vieira
You said you added app successfully with required libraries. I have extracted required libraries and trying to add to OS but its not working. Can you tell me that did you made seprate android.mk file for required libraries of apk and where did you placed those libraries, apk and make files before starting build ?
I want to know these things:
Android.mk file code for apk and its placement ?
Apk placement/location
If separate Android.mk is used for libraries then its location and code ?
Location/placement of libraries before compiling ROM.

Notur Business

unread,
Mar 20, 2021, 1:12:42 PM3/20/21
to android-platform
don't modify files they may change.  well.  .mk world files can change and effect those who rely on them also.  se la vie.  but your right.
Reply all
Reply to author
Forward
0 new messages