Вы находитесь на странице: 1из 3

On Arrietty build, I find that most of the APKs and framework jar files are accompanied by an .

odex file
This is because the Arrietty file system is odexed. (optimized dex). This means that you cannot simply
install an APP using the adb install command. A process known as deodexing is to be performed and apk
needs to be repacked and signed to get a ready-to-install apk.

Deodexing is the act of getting rid .odex files from the phone. These files are extensions of the android
APK (application packages) files and JAR (code packages that make up most of the android GUI) files
located in the system. You can find the .odex files in /system/app/ and /system/framework/. The
process of deodexing is done by decompiling the .odex files and recompiling them into a .dex format and
placing them inside of the corresponding apk or jar. The purpose of deodexing is to make edits to the
JARs or APKs. Most of the code for the files are inside of the .odex, which can not be recompiled once
they have been decompiled with out deodexing them. This allows us to theme and add extra features
that involve edits to the .smali files (similar to .class files containing java code) inside of the .odex.
Deodexing does take up more storage space on the phone and does slow the phone down, although the
speed decrease is hardly noticeable and is easily matched by a custom kernel with slight improvements.
So, if you happen to edit an app of Arrietty and want to update it without building & reflashing the
whole srec, follow the below approach.
On Unix machine:
U need java virtual machine

1) Convert odex to dex
U can use baksmali.jar to de-assemble and smali.jar to assemble. Download files from
http://code.google.com/p/smali/downloads/list
organize the .odex file and the tools downloaded as below:
deodexing
|--- smali-1.4.0.jar
|--- baksmali-1.4.0.jar
|--- smali
|--- baksmali
|--- Panacamera
|--- PanaCamera.odex
|--- PanaCamera.apk

cd deodexing/Panacamera

disassemble: creates a set of .smali files in the default output folder named out
java -jar ../baksmali-1.4.0.jar -a 15 -x PanaCamera.odex -d ~/linkother/arrietty/arrietty-ics-09-
0716/out/target/product/P-08D/system/framework/
assemble: puts the .smali files into a .dex file
java -jar ../smali-1.4.0.jar out -a 15 -o classes.dex

Note:
1. Instead of java -jar ../baksmali-1.4.0.jar we can use ../baksmali
Similarly, instead of java -jar ../smali-1.4.0.jar we can use ../smali
after renaming baksmali-1.4.0.jar as baksmali.jar and smali-1.4.0.jar as smali.jar

2. -a is the API level which can be checked here, if you know android version:
http://source.android.com/source/build-numbers.html

2) unpack and repack apk
change extension of apk to zip
put the classes.dex inside the zip
remove META-INF fodler
change extension to apk again

On Windows machine (instructions mentioned are for windows)
3) Sign ur apk and install (reference 1)
Make sure JDK is installed and the bin folder is included in the PATH environment variable
keytool -genkey -v -keystore myCertificate.keystore -alias m yKey -keyalg RSA -keysize 2048 -validity
20000
It will ask a set of Questions and you need to set the password for the key.
jarsigner -verbose -keystore myCertificate.keystore -digestalg SHA1 -sigalg MD5withRSA
PanaCamera.apk myKey
jarsigner -verify -verbose -certs PanaCamera.apk
result should be jar verified
zipalign -v 4 PanaCamera.apk PanaCamera.zipaligned.apk
result should be Verification Successful
Install the app as usual
adb install PanaCamera.zipaligned.apk
Note:
1. If you do not remove the META-INF folder you will end up jarsigner verification failure:
jarsigner: java.lang.SecurityException: invalid SHA1 signature file digest for r
es/drawable-sw600dp-mdpi/btn_pan_shutter_recording_pressed_holo.png
References:
1. http://www.coderzheaven.com/2011/04/01/android-signing-apk/

2. http://developer.android.com/tools/publishing/app-signing.html#signapp
3. http://forum.xda-developers.com/showthread.php?t=537779
4. http://code.google.com/p/smali/w/list

Вам также может понравиться