How to deploy module with odex?

1,594 views
Skip to first unread message

yf...@mobvoi.com

unread,
Jan 27, 2016, 6:33:37 PM1/27/16
to Android Building
I'm writing some modules based on aosp 5.1, every time I use `mmm vender/PATH_OF_MY_APP`, it will create a odex file. funny thing is that even I claimed LOCAL_DEX_PREOPT := false in my Android.mk file, the odex file will still be generated. If I use `adb install -r myapp.apk`, it will show Failure [INSTALL_FAILED_DEXOPT], if I use `adb push`, no matter push single apk or apk with odex, no matter reboot or not, the application on the board seems no change. The only way to make things works for me is use `make` and burn the image to the board. Since every one says that LOCAL_DEX_PREOPT := false will solve this problem, why my Android.mk still generate odex? And what is the usual way to deploy a module?

Arne-Christian Blystad

unread,
Feb 1, 2016, 10:51:07 AM2/1/16
to Android Building
Do you have WITH_DEXPREOPT enabled in your BoardConfig.mk? Best solution I found was to just turn that off for development builds. For release builds (built on our build server) we have it turned on.

You could also try deleting the file from /data/dalvik-cache/arm/your module (it has a longer name, for example: system@priv-app@Sh...@Shell.apk@classes.dex).

liuyafei

unread,
Feb 2, 2016, 2:09:40 AM2/2/16
to android-...@googlegroups.com
Modify BoardConfig.mk works for me, the BoardConfig.mk override the LOCAL_DEX_PREOPT in my case
--
--
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.

Jacob Abrams

unread,
Feb 1, 2017, 9:09:11 PM2/1/17
to Android Building
I'm working on a Marshmallow system and having more problems than ever. LOCAL_DEX_PREOPT is just the first step. Then I ran into linux permission trouble and SELinux...

When pushing the system APK I get errors such as:

02-01 20:58:26.302 E/dex2oat ( 3045): Failed to create oat file: /data/dalvik-cache/arm64/system@priv-app@x...@xyz.apk@classes.dex: Permission denied

[ 1614.216323] type=1400 audit(686361.299:48): avc: denied { write } for pid=2640 comm="oid.xyz" name="arm64" dev="dm-0" ino=360453 scontext=u:r:system_app:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=0

To fix this stuff I had to modify app_main.cpp:

+    // For engineers, needed to allow pushing locally built APKs
+    int dalvikCacheDirAid = AID_ROOT;
+    char prop[PROP_VALUE_MAX];
+    if (property_get("ro.build.type", prop, NULL) != 0) {
+        if (strcmp("eng", prop) == 0) {
+            dalvikCacheDirAid = AID_SYSTEM;
+        }
+    }

    // We always perform these steps because the directory might
    // already exist, with wider permissions and a different owner
    // than we'd like.
-    result = chown(dalvikCacheDir, AID_ROOT, AID_ROOT);
+    result = chown(dalvikCacheDir, dalvikCacheDirAid, dalvikCacheDirAid);

Then I had to make changes to SELinux...

system_app.te:

+userdebug_or_eng(`
+  allow system_app dalvikcache_data_file:file rw_file_perms;
+  allow system_app dalvikcache_data_file:dir rw_dir_perms;
+')

domain.te:

neverallow {
  domain
  -init # TODO: limit init to relabelfrom for files
  -zygote
  -installd
  -dex2oat
+  userdebug_or_eng(`
+    -system_app
+  ')
} dalvikcache_data_file:file no_w_file_perms;

neverallow {
  domain
  -init
  -installd
  -dex2oat
  -zygote
+  userdebug_or_eng(`
+    -system_app
+  ')
} dalvikcache_data_file:dir no_w_dir_perms;

Pretty ugly, maybe there is an easier way?

On Monday, February 1, 2016 at 11:09:40 PM UTC-8, liuyafei wrote:
Modify BoardConfig.mk works for me, the BoardConfig.mk override the LOCAL_DEX_PREOPT in my case

On 2016年02月01日 22:47, Arne-Christian Blystad wrote:
Do you have WITH_DEXPREOPT enabled in your BoardConfig.mk? Best solution I found was to just turn that off for development builds. For release builds (built on our build server) we have it turned on.

You could also try deleting the file from /data/dalvik-cache/arm/your module (it has a longer name, for example: sys...@priv-app@Shell@Shell.a...@classes.dex).

On Thursday, 28 January 2016 00:33:37 UTC+1, yf...@mobvoi.com wrote:
I'm writing some modules based on aosp 5.1, every time I use `mmm vender/PATH_OF_MY_APP`, it will create a odex file. funny thing is that even I claimed LOCAL_DEX_PREOPT := false in my Android.mk file, the odex file will still be generated. If I use `adb install -r myapp.apk`, it will show Failure [INSTALL_FAILED_DEXOPT], if I use `adb push`, no matter push single apk or apk with odex, no matter reboot or not, the application on the board seems no change. The only way to make things works for me is use `make` and burn the image to the board. Since every one says that LOCAL_DEX_PREOPT := false will solve this problem, why my Android.mk still generate odex? And what is the usual way to deploy a module?
Reply all
Reply to author
Forward
0 new messages