Re:Facebook iOS SDK Remotely Crashing Spotify, TikTok, Pinte...
by grishka on Thursday May 07, 2020 @05:50PM
(#23108769)
You can hack things through reflection. You can use Gradle directives to specifically exclude certain dependencies of your dependencies. You can use ProGuard to strip out the parts of libraries you don't need.
A side note: on Android, class loaders are definitely of no use for this purpose. Android runtime uses its custom bytecode language and file format that packs the entire classpath of your app into one .dex file. You can't load separate classes from these, only the entire thing all at once.
(yes there's multidex for large apps but the way classes are split between files is rather random in my experience)
And I think you can even control the loading through a custom class loader.
It's a bit of work but it should give you decent oversight over the dependencies you really don't trust but have to use.