Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassCastException in AndroidScanner #1474

benoitdevos opened this issue Nov 22, 2016 · 2 comments

ClassCastException in AndroidScanner #1474

benoitdevos opened this issue Nov 22, 2016 · 2 comments


Copy link

@benoitdevos benoitdevos commented Nov 22, 2016

Flyway sometimes crashes on Android 4.2 - 4.4, because a wrong ClassLoader is injected in AndroidScanner.
java.lang.ClassCastException:$WarningContextClassLoader cannot be cast to dalvik.system.PathClassLoader
It is not clear why Android sometimes decides to use this WarningContextClassLoader, but it's a valid ClassLoader and should then be supported by Flyway.

What version of Flyway are you using?


Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)

Java API

What database are you using (type & version)?

(android.database.sqlite.SQLiteDatabase, api level 24 )

What operating system are you using?

Android 4.2 (JellyBean), Android 4.4 (KitKat)

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

        DroidDataSource dataSource = new DroidDataSource(context.getPackageName() + "/databases", dbName);
        flyway = new Flyway();
        flyway.setBaselineDescription("Initial baseline");;

where context is the Application Context of my Android App.

What did you expect to see?
What did you see instead?

An exception is thrown :

java.lang.ClassCastException:$WarningContextClassLoader cannot be cast to dalvik.system.PathClassLoader<init> (
    org.flywaydb.core.internal.util.scanner.Scanner.<init> (
    org.flywaydb.core.Flyway.execute ( (
Copy link
Contributor Author

@benoitdevos benoitdevos commented Nov 25, 2016

A pull request has been submitted.

axelfontaine added a commit that referenced this issue Jan 25, 2017
Fixed ClassCastException in AndroidScanner #1474
axelfontaine added a commit to flyway/ that referenced this issue Jan 25, 2017
@axelfontaine axelfontaine added this to the Flyway 4.1 milestone Jan 25, 2017
Copy link

@axelfontaine axelfontaine commented Jan 25, 2017

PR merged. Thanks!

pradheeps pushed a commit to pradheeps/flyway that referenced this issue Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.