Microsoft Releases Final Builds of Office for Android

Late last year, Microsoft released a preview of Office for Android, initially as an … more

Samsung Cutting Bloat, Trimming TouchWiz

Reports keep iterating over the rumors that Samsung has been trimming down TouchWiz for its upcoming … more

Google Giving Away Inbox Invites for the Next 24 Hours

Google’s biggest email rethink since the launch of Gmail, Inbox, was launched as … more

Get Extra Note 3 (5.0) Features with this Mod

Dislike the S-Finder and Search buttons in your notification shade? Want to customize your … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Q] Not loading class from Classes2.dex?

OP cryptyk

20th August 2014, 02:17 AM   |  #1  
OP Recognized Contributor
Thanks Meter: 2,415
 
575 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, 08:39 PM   |  #2  
GermainZ's Avatar
Forum Moderator / Recognized Developer / XDA Portal Team
Thanks Meter: 7,511
 
6,046 posts
Join Date:Joined: Aug 2012
More
Looks like you got this fixed. What was the problem?
22nd August 2014, 03:53 AM   |  #3  
OP Recognized Contributor
Thanks Meter: 2,415
 
575 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, 08:47 AM   |  #4  
Kevin M's Avatar
Senior Member
Flag Bel Air, MD
Thanks Meter: 176
 
189 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, 09:50 AM   |  #5  
M66B's Avatar
Recognized Developer
Flag Dordrecht
Thanks Meter: 10,636
 
5,834 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, 04:17 AM   |  #6  
Kevin M's Avatar
Senior Member
Flag Bel Air, MD
Thanks Meter: 176
 
189 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