can we use odex file optimization for all apps?

Search This thread

miclaro

Member
Feb 9, 2009
6
0
If it's possible (which it's probably not, since no one has put this out there yet), could someone compile a script or give us a command to only delete and update odex files which are new or modified since last script run? Sounds really complicated to me, but just throwing it out there for thought. I think we all can agree it sucks to run the scripts to recreate every file when we just update or install 1 or 2 .apk's. Some sort of attribute difference search or something. Of course, I'm not holding my breath on this one, but I think we would all appreciate this. Thanks.

as requested:

find /data/app -name "*.apk" -mtime -1 -exec programm {} \;

that gives the files modified in the last day and execute the programm.. giving it the file name as a parameter
 

miclaro

Member
Feb 9, 2009
6
0
the full script would be:

for i in `find /data/app -name "*.apk" -mtime -1 -print`
do

odex=`echo $i | sed -e 's/.apk/.odex/g'`
if [ -f $odex ] ; then
rm $odex
fi
echo "dexopt-wrapper $i $odex"
dexopt-wrapper $i $odex
done

just tried it and it works
 

pelo88

Senior Member
May 17, 2009
116
36
Here's my script that takes a bit from what everyone already does

Code:
for i in /system/app/*.apk

do

   odex=`echo $i | sed -e 's/.apk/.odex/g'`

   i_time=`stat -t $i | cut -d' ' -f14`
   o_time=0

   if [ -f $odex ] ; then 
      o_time=`stat -t $odex | cut -d' ' -f14`
   fi

   if [ $i_time -gt $o_time ] ; then
      if [ -f $odex ] ; then
         rm $odex
      fi
      echo "dexopt-wrapper $i $odex"
      dexopt-wrapper $i $odex
   fi

done

for i in /system/app/*.odex

do

   apk=`echo $i | sed -e 's/.odex/.apk/g'`

   if [ ! -f $apk ] ; then
      rm $i
   fi

done

echo "----------- System Apps DONE -----------"

for i in /data/app/*.apk

do

   odex=`echo $i | sed -e 's/.apk/.odex/g'`

   i_time=`stat -t $i | cut -d' ' -f14`
   o_time=0

   if [ -f $odex ] ; then 
      o_time=`stat -t $odex | cut -d' ' -f14`
   fi

   if [ $i_time -gt $o_time ] ; then
      rm $odex
      echo "dexopt-wrapper $i $odex"
      dexopt-wrapper $i $odex
   fi

done

for i in /data/app/*.odex

do

   apk=`echo $i | sed -e 's/.odex/.apk/g'`

   if [ ! -f $apk ] ; then
      rm $i
   fi

done

echo "----------- Market Apps DONE -----------"
It creates new odex files for any apks that don't have an odex or have an older odex and it removes odex files for any removed apk, first it does this for system files then it does this for data files (market apps).
 

Attachments

  • odex.zip
    384 bytes · Views: 280
Last edited:

enatefox

Senior Member
Jul 4, 2008
1,846
3
Maybe I'm failing here, I tried to run it (on Donut but shouldn't matter) and got this error for each:
dexopt-wrapper /system/app/Vending.apk /system/app/Vending.odex
--- BEGIN '/system/app/Vending.apk' (bootstrap=0) ---
--- would reduce privs here
--- waiting for verify+opt, pid=2490
--- END '/system/app/Vending.apk' --- status=0xff00, process failed
All the odexes are 0-byte. Any ideas?

I found the source code for it here but don't see the condition that is met to throw the error.
 
Last edited:

htcmagic

Senior Member
Jul 8, 2009
393
5
Could somebody please put the command from adb shell to create odex file for a single apk?

Thanks
 

overground

Retired Senior Moderator / Inactive Recognized Dev
Could somebody please put the command from adb shell to create odex file for a single apk?

Thanks

You can try this...no guarantees. Needless to say !!USE AT YOUR OWN RISK!!

Edit below commands replacing instances of * with desired FULL app name. If the app you're odexing does not reside in /data/app/ - replace with correct path. Save as /sdcard/odex.sh or change path and filename to preference. Easiest IMO to run with Gscript. Good luck. I quit doing this a long time ago. The hassle/problems didn't seem worth the barely noticeable speed gains.

Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblk3 /system
rm /data/dalvik-cache/data@app@*.dex
rm /data/app/*.odex
for i in /data/app/*.apk
do
odex=`echo $i | sed -e 's/.apk/.odex/g'`
echo "dexopt-wrapper $i $odex"
dexopt-wrapper $i $odex
done

After editing run:

Code:
su
sh /<path to script>/scriptname.sh

Again...untested for several months.
 

-= sk0t =-

Member
May 4, 2010
9
55
Maybe I'm failing here, I tried to run it (on Donut but shouldn't matter) and got this error for each:

dexopt-wrapper /system/app/Vending.apk /system/app/Vending.odex
--- BEGIN '/system/app/Vending.apk' (bootstrap=0) ---
--- would reduce privs here
--- waiting for verify+opt, pid=2490
--- END '/system/app/Vending.apk' --- status=0xff00, process failed

All the odexes are 0-byte. Any ideas?

You must specify BOOTCLASSPATH
Code:
dexopt-wrapper /system/framework/services.jar /system/framework/services.odex [COLOR="Red"]/system/framework/core.jar:/sys
tem/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar[/COLOR]
You can find right BOOTCLASSPATH in file init.rc
 

Top Liked Posts