ClassLoader to replace a pre-loaded class?

General question:
Is it possible to use a ClassLoader to replace a pre-loaded (by the system, e.g. found in Android’s %android%/frameworks/base/preloaded-classes file) class?

I am attempting to use the DexClassLoader to replace a class found in* before creating a WebView in my application. I can get a Class object, but getMethods() for example gives me an array I’d expect in the unmodified/original class implementation. Is this due to the preloaded-classes system?

  • IllegalArgumentException: provider doesn't exisit: null on Maps V1
  • AsyncTask and Contexts
  • How can I customize the code that is generated when I use “Surround with try/catch”?
  • Android Java UTF-8 HttpClient Problem
  • Multiple Clickable links in TextView on Android
  • Using a ListAdapter to fill a LinearLayout inside a ScrollView layout
  • Basic setup & pseudo code:

    1. Modify* class, adding a few test methods/etc.
    2. Compile and end up with classes.dex
    3. jar cf mytest.jar classes.dex
    4. Include mytest.jar in APK assets
    5. Create DexClassLoader and get Class via loadClass()
    6. getMethods() on Class object returns an array I’d expect to see without modifications present in #1

    I can provide more details on the setup I’m using and code if needed.

    Related posts:

    Android ActionBar MenuItem LowerCase
    Android Linkify both web and @mentions all in the same TextView
    How reliable is LocationManager's getLastKnownLocation and how often is it updated?
    Android how to apply mask on ImageView?
    Add Google Analytics Library to a Maven Project
    How to increase the height of table row according to screens?
  • Android Facebook 4.0 SDK How to get Email, Date of Birth and gender of User
  • Android Notification intent to clear it self
  • How to make missed calls?
  • Textbox hidden below keyboard in Android webview
  • Espresso test recording feature in Android Studio 2.2
  • Android: Something better than android:ellipsize=“end” to add “…” to truncated long Strings?
  • One Solution collect form web for “ClassLoader to replace a pre-loaded class?”

    No you can not. WebView is part of the boot class path, and thus the base class loader. There is nothing you can do to make it use classes in another class loader. In fact, it has already been loaded and linked to the classes it uses before your app is even launched (as part of the zygote process pre-initialization).

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.