notishell / smali

Automatically exported from code.google.com/p/smali
0 stars 0 forks source link

bootclasspath - /system/app/gtalkservice.odex de-odex error #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. De-odex /system/framework/com.google.android.gtalkservice.odex first
2. De-odex /system/app/gtalkservice.odex, and got dependence errors even 
if "-Xbootclasspath/a:.\framework\gtalkservice" is used. 

What is the expected output? What do you see instead?

Please see errors in the additional section below.

What version of the product are you using? On what operating system?
Windows Vista 32, JDK 1.6.17, ADP2/Sapphire phone.

Please provide any additional information below.

C:\android-sdk_r04\recovery\smali>java -
Xbootclasspath/a:.\framework\gtalkservice -Xss1m -X
mx512M -jar baksmali.jar -x :1234 app\gtalkservice\gtalkservice.odex

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: java.lang.RuntimeException: class 
Lcom/google/android/gtalkservice/Group
ChatInvitation; could not be found for common superclass lookup. This can 
be caused if a library the
 odex depends on is not in the BOOTCLASSPATH environment variable
        at org.jf.dexlib.Util.Deodexerant.sendCommand(Deodexerant.java:193)
        at org.jf.dexlib.Util.Deodexerant.lookupCommonSuperclass
(Deodexerant.java:167)
        at org.jf.dexlib.Util.DeodexUtil$insn.findCommonSuperclass
(DeodexUtil.java:1241)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters
(DeodexUtil.java:1412)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters
(DeodexUtil.java:1466)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters
(DeodexUtil.java:1466)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters

.....................

(DeodexUtil.java:1466)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters
(DeodexUtil.java:1466)
        at org.jf.dexlib.Util.DeodexUtil.makeInsnList(DeodexUtil.java:188)
        at org.jf.dexlib.Util.DeodexUtil.deodexerizeCode
(DeodexUtil.java:194)
        at 
org.jf.baksmali.Adaptors.MethodDefinition$MethodItemList.generateMethodItem
List(MethodDef
inition.java:207)
        at org.jf.baksmali.Adaptors.MethodDefinition.getMethodItems
(MethodDefinition.java:158)
        at org.jf.baksmali.Adaptors.MethodDefinition.makeTemplate
(MethodDefinition.java:62)
        at org.jf.baksmali.Adaptors.ClassDefinition.getDirectMethods
(ClassDefinition.java:255)
        at org.jf.baksmali.Adaptors.ClassDefinition.makeTemplate
(ClassDefinition.java:75)
        at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:120)
        at org.jf.baksmali.main.main(main.java:198)
Caused by: java.lang.RuntimeException: class 
Lcom/google/android/gtalkservice/GroupChatInvitation; c
ould not be found for common superclass lookup. This can be caused if a 
library the odex depends on
is not in the BOOTCLASSPATH environment variable
        at org.jf.dexlib.Util.Deodexerant.sendCommand(Deodexerant.java:189)
        ... 104 more

Original issue reported on code.google.com by me95...@gmail.com on 1 Jan 2010 at 4:37

GoogleCodeExporter commented 9 years ago
You need to set the BOOTCLASSPATH environment variable on the *phone*. Not on 
your
computer :)

adb shell
BOOTCLASSPATH=$BOOTCLASSPATH:/system/framework/com.google.android.gtalkservice.j
ar
deodexerant /system/app/gtalkservice.odex 1234 &
exit
tcp forward tcp:1234 tcp:1234
baksmali gtalkservice.odex -x :1234

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 5:31

GoogleCodeExporter commented 9 years ago
dedexer can de-odex "app\gtalkservice\gtalkservice.odex" without problems.

Original comment by me95...@gmail.com on 1 Jan 2010 at 5:32

GoogleCodeExporter commented 9 years ago
Also, for the record, you don't have to deodex
/system/framework/com.google.android.gtalkservice.odex first. You can just 
deodex
/system/app/gtalkservice.odex, if that's all that you're interested in.

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 5:32

GoogleCodeExporter commented 9 years ago
baksmali/deodexerant can deodex it fine. You just have to do it correctly.

Also: interesting. I wasn't aware dedexer could do deodexing now.

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 5:34

GoogleCodeExporter commented 9 years ago
Yes. dedexer can do odex files now. I just tried other odex files 
with "baksmali/deodexerant", and most of them are fine (Calculator.odex etc. 
worked 
well). However, I had a similar problem with "GmailProvider.odex", see below:

C:\android-sdk_r04\smali>java -Xss1m -Xmx512M -jar baksmali.jar -x :1234 
GmailProv
ider.odex

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: java.lang.RuntimeException: class 
Lcom/google/android/gtalkservice/GTalkHttpClient; could not be found for common 
superclass lookup
        at org.jf.dexlib.Util.Deodexerant.sendCommand(Deodexerant.java:193)
        at org.jf.dexlib.Util.Deodexerant.lookupCommonSuperclass
(Deodexerant.java:167)
        at org.jf.dexlib.Util.DeodexUtil$insn.findCommonSuperclass
(DeodexUtil.java:1241)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters
(DeodexUtil.java:1412)
        at org.jf.dexlib.Util.DeodexUtil$insn.propagateRegisters
(DeodexUtil.java:1466)

Original comment by me95...@gmail.com on 1 Jan 2010 at 6:06

GoogleCodeExporter commented 9 years ago
You just need to add the extra dependency jar to the BOOTCLASSPATH environment
variable on the *phone*, before running deodexerant.

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 6:07

GoogleCodeExporter commented 9 years ago
 "/system/app/MarketUpdater.odex" is good with "baksmali/deodexerant". Just 
that "/system/app/gtalkservice.odex" and "/system/app/GmailProvider.odex" have 
dep 
problems, not be de-odexed at this point. This is from Google ADP2/Sapphire rom.

Original comment by me95...@gmail.com on 1 Jan 2010 at 6:10

GoogleCodeExporter commented 9 years ago
I do want to add functionality to deodexerant so that it reads the dependencies 
from
the odex file and automatically sets the bootclasspath appropriately. But for 
now,
you have to set it before calling it :)

I haven't taken a look at dedexer in a while. It looks like he's been doing 
some work
on it :) 

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 6:10

GoogleCodeExporter commented 9 years ago

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 6:13

GoogleCodeExporter commented 9 years ago
Thanks JF! 
Yes. After export 
BOOTCLASSPATH=$BOOTCLASSPATH:/system/framework/com.google.android.gtalkservice.j
ar, 
it works perfect now!

Original comment by me95...@gmail.com on 1 Jan 2010 at 6:28

GoogleCodeExporter commented 9 years ago
How come dedexer can do it offline on host, and has no dependence issue?

Original comment by me95...@gmail.com on 1 Jan 2010 at 6:38

GoogleCodeExporter commented 9 years ago
It's because he took a different path to deodex stuff than I did. When a dex 
file is
odexed, various instructions are replaced with an "optimized" version of the
instruction. For things like invoke-virtual, instead of directly specifying the 
name
of the method that should be invoked, the odex instruction instead contains the 
index
into the vtable that dalvik keeps for each class.

What dedexer does (or appears to do, I haven't looked at the source much yet), 
is to
load the dependency odex files, and recreate the virtual tables, so that he can
resolve the virtual table indexes in the odexed instructions. Like most things, 
his
approach is a trade-off. On the positive side, it is a lot easier to use, since 
you
don't have to be running a helper binary on a device. On the negative side, it's
possible that dalvik's internal representation of the vtable will change, and 
his
deodexer will no longer work with the new format, without changes.

On the other hand, I chose to use a method that is more robust, but is more 
difficult
to use. My method should be able to handle changes in dalvik's internal
representation easier, but it's more difficult to use.

Original comment by JesusFre...@gmail.com on 1 Jan 2010 at 6:58