Skip to content

Support BaseDexClassLoader in AppDataDirGuesser#212

Open
lev-rumyantsev wants to merge 1 commit into
linkedin:mainfrom
lev-rumyantsev:support-basedexclassloader
Open

Support BaseDexClassLoader in AppDataDirGuesser#212
lev-rumyantsev wants to merge 1 commit into
linkedin:mainfrom
lev-rumyantsev:support-basedexclassloader

Conversation

@lev-rumyantsev

Copy link
Copy Markdown

AppDataDirGuesser was strictly casting the ClassLoader to PathClassLoader.
This fails if the test is run under a different ClassLoader (like DexClassLoader
or InMemoryDexClassLoader), which can happen in automated test runs or guest
execution environments.

By casting to BaseDexClassLoader instead, we support all standard Android
class loaders since they all inherit from BaseDexClassLoader and use DexPathList
internally.

Also added a fallback to ActivityThread.currentApplication().getCacheDir()
if the class loader guessing still fails.

AppDataDirGuesser was strictly casting the ClassLoader to PathClassLoader.
This fails if the test is run under a different ClassLoader (like DexClassLoader
or InMemoryDexClassLoader), which can happen in automated test runs or guest
execution environments.

By casting to BaseDexClassLoader instead, we support all standard Android
class loaders since they all inherit from BaseDexClassLoader and use DexPathList
internally.

Also added a fallback to ActivityThread.currentApplication().getCacheDir()
if the class loader guessing still fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant