XDA Picks: Best Apps of the Week (Apr 17 – 24)

Apps are at the front and center of any smartphone experience, and with over a … more

Glimpse Notifications: Easier Lockscreen Notifications

Lollipop brought a revamp to the lockscreen, taking away custom widgets but … more

What Are the Best Looking Apps on Android?

As more developers are updating their apps with Material Design elements, we’re … more

Cyngn Explained: Who’s Cyanogen, What’s Cyanogen OS?

While Cyanogen, Inc has been the source of many headlines lately, there … 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,665
 
More
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,164
 
More
Looks like you got this fixed. What was the problem?
22nd August 2014, 02:53 AM |#3  
OP Recognized Contributor
Thanks Meter: 2,665
 
More
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: 294
 
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
Thanks Meter: 11,311
 
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: 294
 
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