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?

  • Dismiss a custom dialog?
  • Android Universal Image Loader requests with same URL are being cancelled
  • How to get the first visible View from an Android ListView
  • Read Newer Theme Attributes On Older Platform
  • Accessing WiFi LAN (no gateway) and mobile network simultaneously
  • AndroidStudio gradle proxy
  • 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:

    How can I change font size in PreferenceScreen
    Android - popover controller same as ipad
    Why am I getting “Unsupported format” errors, reading H.264 encoded rtsp streams...
    How to build i686-linux-android-gfortran for android-ndk8b (x86 arch Android)?
    Get mp3 duration in android
    How to change color of soft keyboard “Enter”/“Next” button o...
  • LayoutInflater.Factory onCreateView is not called with 22.1+ support library
  • Drawing top border on a shape on Android
  • ViewPager call setUserVisibleHint after first Fragment is loaded
  • Finite State Machine (FSM) and Android's Java
  • Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'
  • 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.