I am working on an App which is meant to use the Renderscript Support Library. For development Android Studio 0.5.4 and Gradle 1.11 is used.
To configure renderscript I use
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
renderscriptTargetApi 19
renderscriptSupportMode true
}
}
This works on 2.3 and 4.4.2.
After my first screen I wanted to write a few tests to document. Atm I use ActivityUnitTestCase as the ancestor for the tests.. My test code is in src/androidTest/java and is identified by Android Studio as a src directory. I can also successfully start the test case using a real device. The test case itself just verifies the existence of a few views. However the tests fail because of:
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
Further down in the stack trace I see that its triggered shortly before the first renderscript invocation. Having a look inside the generated (not obfuscated) apk shows that the Instrumentation Test apk contains the android.support.v8.renderscript package.
So the exception arises because both the apk under test and the test include the renderscript package.
My Question: How to prevent it?
I use several libraries and they do not appear in the test apk. Just the renderscript library does with both dex files and shared objects. I assume its due to its deep native complexity that its treated differently than libraries like nineoldandroids etc.
My Google-Fu revealed that there are only workarounds, one of them being http://www.sinking.in/blog/android-dependency-double-trouble/ Which also mentions the inheritent problem http://issues.gradle.org/browse/GRADLE-784
But non of the fixes mentioned there apply to the renderscript lib.
Im thankful for any hint. Thank you.