Open mik9 opened 6 years ago
If you have a custom AndroidJUnitRunner
, please make sure that the class literal of your Application class is not used on AndroidJUnitRunner#newApplication
.
It would be helpful if you can share a minimal project that can reproduce this issue.
My newApplication
method looks like next (TestApp
class that extends App
class from main module):
@Override
public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
DexOpener.builder(context)
.buildConfig(BuildConfig.class)
.build()
.installTo(cl);
return super.newApplication(cl, TestApp.class.getName(), context);
}
I will try to setup simple project with this issue.
Don't call TestApp.class.getName()
on newApplication()
.
Instead, use a string literal of the Application class name.
return super.newApplication(cl, "your.app.test.TestApp", context);
Tried using raw string: still same exception.
Currently can't identify what of my code cause this to setup minimal project... The only thing I see that: this classes was generated by Dagger (subcomponent builders).
Also I use multidex for debug builds, but as I see, all this classes in exception located in a single dex...
Just found the corresponding issue in the google bug tracker, if anyone is interested. https://issuetracker.google.com/issues/75295983
Exception message in runtime:
Class 'ua.pl.mik.app.DaggerAppComponent$SomeLongNameBuilder' does not implement interface 'ua.pl.mik.app.net.ApiComponent$Builder' in call to 'ua.pl.mik.app.net.ApiComponent ua.pl.mik.app.net.ApiComponent$Builder.build()
Class names was changed a bit. On Android 7.0+ same apks (main + androidTest) working fine.