Unofficial CM12.1 Available for Moto E 2014

While Motorola is yet to release a final 5.0.2 build for the Moto E 2014, XDA Senior … more

Pinsy Brings Social Sketching To Your Watch & Phone

Did you watch Apple’s VP draw on his wrist during the Apple Watch announcement … more

CyanogenMod 12.1 for Samsung Galaxy S5

Android 5.1 is slowly putting its mark in the custom ROM world. CyanogenMod 12.1 is available to … more

Nexus Player 5.1 LMY47D Rooted

We recently featured the Nexus Player, Google’s second attempt at a digital media … more
Post Reply Subscribe to Thread Email Thread

[Q] Not loading class from Classes2.dex?

20th August 2014, 01:17 AM   |  #1  
OP Recognized Contributor
Thanks Meter: 2,652
 
630 posts
Join Date:Joined: Jul 2007
I'm trying to hook the following: com.google.android.ulr.ApiRate

It's in com.google.android.gms (Google Play Services). I verified it's in there by dex dumping the Classes2.dex from Play Services.

At runtime, I get this:
Code:
de.robv.android.xposed.XposedHelpers$ClassNotFoundError: java.lang.ClassNotFoundException: com.google.android.ulr.ApiRate
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.ulr.ApiRate" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/data/app/com.google.android.gms-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.android.gms-2, /vendor/lib, /system/lib, /vendor/lib]]
The only thing I can think of is that it's because it's in Classes2.dex instead of Classes.dex?

Any thoughts?
21st August 2014, 07:39 PM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 8,019
 
6,136 posts
Join Date:Joined: Aug 2012
More
Looks like you got this fixed. What was the problem?
22nd August 2014, 02:53 AM   |  #3  
OP Recognized Contributor
Thanks Meter: 2,652
 
630 posts
Join Date:Joined: Jul 2007
Quote:
Originally Posted by GermainZ

Looks like you got this fixed. What was the problem?

I wasn't able to fix it. I tried using multidex but never got it working. In the end, i had to dig through a lot of projects dalvik bytecode and follow the call stack back to a place defined in classes.dex, then hook it there. Not ideal, and more chances for side effects, but things seem to be working

I'd love to see a fix at some point!
The Following User Says Thank You to cryptyk For This Useful Post: [ View ]
28th December 2014, 07:47 AM   |  #4  
Kevin M's Avatar
Senior Member
Flag Bel Air, MD
Thanks Meter: 271
 
232 posts
Join Date:Joined: Jul 2011
Donate to Me
More
Quote:
Originally Posted by cryptyk

I wasn't able to fix it. I tried using multidex but never got it working. In the end, i had to dig through a lot of projects dalvik bytecode and follow the call stack back to a place defined in classes.dex, then hook it there. Not ideal, and more chances for side effects, but things seem to be working

I'd love to see a fix at some point!

Could you point me in the right direction here? com.google.android.a.r seems to be pretty close. Lots of references to DexClassLoader.
28th December 2014, 08:50 AM   |  #5  
M66B's Avatar
Recognized Developer
Flag Dordrecht
Thanks Meter: 11,138
 
6,056 posts
Join Date:Joined: Aug 2010
Donate to Me
More
Quote:
Originally Posted by cryptyk

I'm trying to hook the following: com.google.android.ulr.ApiRate

It's in com.google.android.gms (Google Play Services). I verified it's in there by dex dumping the Classes2.dex from Play Services.

At runtime, I get this:

Code:
de.robv.android.xposed.XposedHelpers$ClassNotFoundError: java.lang.ClassNotFoundException: com.google.android.ulr.ApiRate
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.ulr.ApiRate" on path: DexPathList[[zip file "/system/framework/com.android.media.remotedisplay.jar", zip file "/system/framework/com.android.location.provider.jar", zip file "/data/app/com.google.android.gms-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.google.android.gms-2, /vendor/lib, /system/lib, /vendor/lib]]
The only thing I can think of is that it's because it's in Classes2.dex instead of Classes.dex?

Any thoughts?

I guess this is caused by using the wrong class loader.

Try finding the class with classForName by specifying another class loader:
http://developer.android.com/referen...g.ClassLoader)

You will need to find a way to get to another class loader though.
29th December 2014, 03:17 AM   |  #6  
Kevin M's Avatar
Senior Member
Flag Bel Air, MD
Thanks Meter: 271
 
232 posts
Join Date:Joined: Jul 2011
Donate to Me
More
Found a surprisingly easy way to hook any class needed from Play Services. Just hook the Application onCreate. It looks like the initial package class loader will only have the initial dex file loaded. After loading the initial application instance GMS will at some point, I'm guessing, load the additional dexes. The GMS Application Context appears to have a fully loaded class loader associated with it. Tapping into that will give you access to whatever you need. Much simpler than I expected and resistant to per-release obfuscation.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes