I'm configuring my project for Instrumentation tests, However When I try to run Android Instrumentation test on an android library module it's returning below error:
java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat.
at androidx.appcompat.widget.ResourceManagerInternal.checkVectorDrawableSetup(ResourceManagerInternal.java:509)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:142)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:480)
at androidx.appcompat.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:94)
at androidx.appcompat.app.AppCompatDelegateImpl.attachToWindow(AppCompatDelegateImpl.java:872)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureWindow(AppCompatDelegateImpl.java:848)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreate(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity$2.onContextAvailable(AppCompatActivity.java:133)
at androidx.activity.contextaware.ContextAwareHelper.dispatchOnContextAvailable(ContextAwareHelper.kt:84)
at androidx.activity.ComponentActivity.onCreate(ComponentActivity.java:378)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:216)
at com.akexorcist.localizationactivity.ui.LocalizationActivity.onCreate(LocalizationActivity.kt:46)
at com.sample.core.presentation.BaseActivity.onCreate(BaseActivity.kt:86)
...
The test I'm trying to run:
@Test
fun test() {
assert(true)
}
Please note that when i run the test on the App module it works perfectly. And the app is building fine.
Here is what I have attempted:
- Adding stuff to my build gradle suggested by others in other questions:
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
- I also tried to add all the dependencies from my app module to the library module but still facing the same problem.
- Cleaning the project, and Invalidating cache and restarting.