[Q] Unpacking native libraries problem. - Android Q&A, Help & Troubleshooting

Hi all!
Maybe it's a simple problem but I can't find a solution over i-net.
I'm trying to incorporate apk into system by changing mk file:
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/data/app
=>
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/system/app
But in this case PackageManager doesn't unpack .so libraries placed inside:
So I successfully get logcat message
I/PackageManager( 92): Unpacking native libraries for /data/app/<myapp>.apk
and unpacked .so in /data/data/<myapp>/lib
when app is placed to /data/app
and nothing when it's written to /system/app. As the result I catch UnsatisfiedLinkError due to missing library.
What's required to force PackageManager unpack native libraries from apk?

Related

[Q] Problem with CWM recovery when building AOKP from source

So I decided to lean how to build AOKP from source. I referenced other developers Github's and multiple tutorials. I finally manged to create a good device and vendor tree and successfully build AOKP from source. All is good, or so I thought. When I attempted to perform my first CWM backup, I was prompted (at the end) with the error message "MD5 error". Looking into the recovery log shows that the script nandroid-md5.sh was not found.
So, I check my build output, "out/target/product/i777/recovery/root/sbin" and discover that the script is missing. Next I start to dig into the bootable/recovery project. I evaluate the Android.mk file and I find the following:
Code:
include $(CLEAR_VARS)
LOCAL_MODULE := nandroid-md5.sh
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_SRC_FILES := nandroid-md5.sh
include $(BUILD_PREBUILT)
So the make file should include the script in the build, but I can't figure out what is missing. I've done the following without success.
Rebuilt with an earlier version (6.0.1.5) of CWM recovery.
Evaluated other devices to see if I'm missing something in my device/vendor trees.
Checked AOKP & CM forums for anyone reporting similar issues.
Built a supported device i9100 and the same problem occurs.
Now, I've found a workaround, but it seems more like a hack. If I include the following line in one of my make files, then the file will get copied.
Code:
PRODUCT_COPY_FILES += \
bootable/recovery/nandroid-md5.sh:recovery/root/sbin/nandroid-md5.sh
I'm hoping that someone can help me understand why my build is having this problem.

Compiling android - trying to add XML files to /system/etc/permissions

I'm compiling android from source. I've set up the environment, and tested the builds. Everything works fine.
My current objective is to add 10 custom xml files to /system/etc/permissions. I've tried modifying the Android.mk file in frameworks/base/data/etc to include the files, but the additions aren't appearing in the compiled system. What's strange is that the default files that were in the same folder and already in the makefile appear, so the makefile seems to be read and parsed at compile.
This is the code I'm using:
Code:
LOCAL_PATH := $(my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := [B]default_file_already_present.xml[/B]
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := [B]my_custom_file.xml[/B]
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
For some reason, my_custom_file is not added, while the default_file_already_present is. Any ideas?
I've searched around, but can't find any decent documentation. I feel like I’m very close, so any help is much appreciated!
tl;dr - Adding files to system partition with makefile partially fails.
Solution!
For those who also run in to this problem:
As per Jean-Baptiste Quéru's post on a google group;
The Android makefiles are essentially split into 2 primary categories,
parsed in this order.
-the product definitions, which specify what modules need to be
installed for each product.
-the module definition, which specify how to build each module.
The build system protects itself against situation where you modify
the product definition from a module definition. PRODUCT_COPY_FILES is
part of the product definition, and can't be modify from a module
definition.
JBQ
Click to expand...
Click to collapse
What this means is that in order to copy files as is to the system image, we need to use product definitions.
What I did was first run ./build/envsetup.sh, in order to get access to commands like mgrep, etc.
I noticed that in frameworks/base/data/keyboards there was a keyboards.mk file, which got included correctly.
I made a copy and modifies it to suit my needs:
Code:
# Copyright (C) 2010 The Android Open Source Project
#
blah blah blah...
#
# This is the list of custom permissions to be injected in /system/etc/permissions
permissionsfiles := \
android.hardware.camera.front.xml \
android.hardware.usb.accessory.xml \
android.hardware.usb.host.xml \
android.hardware.wifi.direct.xml \
android.hardware.wifi.xml \
android.software.sip.voip.xml \
com.google.android.maps.xml \
com.google.android.media.effects.xml \
com.google.widevine.software.drm.xml \
handheld_core_hardware.xml \
platform_plus.xml \
features.xml
PRODUCT_COPY_FILES := $(foreach file,$(permissionsfiles),\
frameworks/base/data/etc/$(file):system/etc/permissions/$(file))
I ran "mgrep keyboards" and noted which makefiles included the keyboards.mk file, then I opened each file and duplicated that line, modifying it to instead include my custom_permissions.mk located in frameworks/base/data/etc/.
I compiled and the files were all there.
Hope this helps.

Compiling android - trying to add XML files to /system/etc/permissions

I'm compiling android from source. I've set up the environment, and tested the builds. Everything works fine.
My current objective is to add 10 custom xml files to /system/etc/permissions. I've tried modifying the Android.mk file in frameworks/base/data/etc to include the files, but the additions aren't appearing in the compiled system. What's strange is that the default files that were in the same folder and already in the makefile appear, so the makefile seems to be read and parsed at compile.
This is the code I'm using:
Code:
LOCAL_PATH := $(my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := [B]default_file_already_present.xml[/B]
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := [B]my_custom_file.xml[/B]
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)
For some reason, my_custom_file is not added, while the default_file_already_present is. Any ideas?
I've searched around, but can't find any decent documentation. I feel like I’m very close, so any help is much appreciated!
tl;dr - Adding files to system partition with makefile partially fails.
Solution!
For those who also run in to this problem:
As per Jean-Baptiste Quéru's post on a google group;
The Android makefiles are essentially split into 2 primary categories,
parsed in this order.
-the product definitions, which specify what modules need to be
installed for each product.
-the module definition, which specify how to build each module.
The build system protects itself against situation where you modify
the product definition from a module definition. PRODUCT_COPY_FILES is
part of the product definition, and can't be modify from a module
definition.
JBQ
Click to expand...
Click to collapse
What this means is that in order to copy files as is to the system image, we need to use product definitions.
What I did was first run ./build/envsetup.sh, in order to get access to commands like mgrep, etc.
I noticed that in frameworks/base/data/keyboards there was a keyboards.mk file, which got included correctly.
I made a copy and modifies it to suit my needs:
Code:
# Copyright (C) 2010 The Android Open Source Project
#
blah blah blah...
#
# This is the list of custom permissions to be injected in /system/etc/permissions
permissionsfiles := \
android.hardware.camera.front.xml \
android.hardware.usb.accessory.xml \
android.hardware.usb.host.xml \
android.hardware.wifi.direct.xml \
android.hardware.wifi.xml \
android.software.sip.voip.xml \
com.google.android.maps.xml \
com.google.android.media.effects.xml \
com.google.widevine.software.drm.xml \
handheld_core_hardware.xml \
platform_plus.xml \
features.xml
PRODUCT_COPY_FILES := $(foreach file,$(permissionsfiles),\
frameworks/base/data/etc/$(file):system/etc/permissions/$(file))
I ran "mgrep keyboards" and noted which makefiles included the keyboards.mk file, then I opened each file and duplicated that line, modifying it to instead include my custom_permissions.mk located in frameworks/base/data/etc/.
I compiled and the files were all there.
Hope this helps.

How to use 3rd party jar in system app

I want to use a 3rd party jar in the system app - Settings.
I have tried two methods, but both failed.
The Android version is 4.2.2 JB.
The first method is that I put the jar file into /packages/apps/Settings/ and modify the Android.mk.
Code:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_JAVA_LIBRARIES := bouncycastle telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := guava android-support-v4 jsr305 nxpnfclib
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := Settings
LOCAL_CERTIFICATE := platform
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := nxpnfclib.jar
include $(BUILD_MULTI_PREBUILT)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH))
Some proguard warnings show up:
Code:
Warning: class [com/nxp/nfclib/ntag/╦К.class] unexpectedly contains class [com.nxp.nfclib.ntag.ˊ]
Warning: there were 30 classes in incorrectly named files. You should make sure all file names correspond
to their class names. The directory hierarchies must correspond to the package hierarchies. If you don't mind
the mentioned classes not being written out, you could try your luck using the '-ignorewarnings' option.
Error: Please correct the above warnings first. make: *** [out/target/common/obj/APPS/Settings_intermed
iates/proguard.classes.jar] Error 1
Then I add some proguard flags to prevent this warnings. I can compile Android now. However, when I boot the system, some errors show up:
Code:
W/dalvikvm( 732): Unable to resolve superclass of Lcom/nxp/nfclib/ntag/NTag213215216; (1855)
W/dalvikvm( 732): Link of class 'Lcom/nxp/nfclib/ntag/NTag213215216;' failed
W/dalvikvm( 732): Unable to resolve superclass of Lcom/nxp/nfclib/ntag/NTag213F216F; (1844)
W/dalvikvm( 732): Link of class 'Lcom/nxp/nfclib/ntag/NTag213F216F;' failed
E/dalvikvm( 732): Could not find class 'com.nxp.nfclib.ntag.NTag213F216F', referenced from method com.nxp.nfclib.NxpNfcLib.ˊ
Another mothod: I put the jar file to /prebuilts/misc/common/nxp and write an Android.mk:
Code:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PREBUILT_JAVA_LIBRARIES := \
nxpnfclib$(COMMON_JAVA_PACKAGE_SUFFIX)
LOCAL_MODULE_TAGS := optional
include $(BUILD_HOST_PREBUILT)
Then modify /packages/apps/Settings/Android.mk:
Code:
LOCAL_STATIC_JAVA_LIBRARIES := guava android-support-v4 jsr305 nxpnfclib
However, when I compile the whole AOSP, the same proguard warnings show up:
Code:
Warning: class [com/nxp/nfclib/ntag/╦К.class] unexpectedly contains class [com.nxp.nfclib.ntag.ˊ]
Warning: there were 30 classes in incorrectly named files. You should make sure all file names correspond
to their class names. The directory hierarchies must correspond to the package hierarchies. If you don't mind
the mentioned classes not being written out, you could try your luck using the '-ignorewarnings' option.
Error: Please correct the above warnings first. make: *** [out/target/common/obj/APPS/Settings_interm
ediates/proguard.classes.jar] Error 1
Is there some other way to add the jar?
The jar runs well if I use Android Studio to build an app.
Can I put the jar in the system instead of merge it into the system?

How to include a native android library on a vendor NDK app

Hi,
It's my first question here, so thank you for this forum!
I want to use Android Native Window functionality on my cpp NDK application.
So, I've added the include to the top of my cpp file:
#include <android/native_window.h>
And added the android library to my Android.mk file:
LOCAL_LDLIBS += -landroid
But get a linker error:
Android.mk: error: "my_app (native:vendor) can not link against libandroid (native::latform)"
Click to expand...
Click to collapse
Is someone known how can I use the NativeWindow API on my vendor application?
Thanks a lot!
Netanel

Categories

Resources