androidscalaproguardscala-reflectsbt-android-plugin

Testing Scala on Android : "Couldn't find scala.reflect.ScalaSignature.bytes"


I am trying to write instrumentation test in Scala (full code is here).

Any ideas what might be causing the java.lang.IncompatibleClassChangeError: Couldn't find scala.reflect.ScalaSignature.bytes run-time error ?

I am trying to keep scala.reflect.ScalaSignature.bytes in the build.sbt:

proguardOptions ++=
    "-dontwarn android.test.**" ::
    "-dontwarn org.scalatest.**" ::
    "-dontwarn scala.xml.**" ::
    "-dontwarn slick.jdbc.**" ::
    "-dontwarn org.slf4j.**" ::
    "-dontwarn org.junit.**" ::
    "-dontobfuscate" ::
    "-dontnote ** "  ::
    "-dontpreverify" ::
    "-optimizations !code/simplification/arithmetic" ::
    "-keep class android.support.test.** { *; }" ::
    "-keep class scala.reflect.ScalaSignature.** {*;}" ::
    "-keep class com.mypackage.** { *; }" ::
    "-keep class * extends junit.framework.TestCase { *; }" ::
    "-keepclasseswithmembers class * { @org.junit.** *; }" ::
    "-keepclassmembers class * { ** bytes();}"::
    "-keep class android.support.test.** { *; }" ::
    "-keep class org.junit.** { *; }" ::
    Nil

but it does not seem to help.

Full stack trace:

 E  ( 9562) TestExecutor: Fatal exception when running tests
 E  ( 9562) TestExecutor: java.lang.IncompatibleClassChangeError: Couldn't find scala.reflect.ScalaSignature.bytes
 E  ( 9562) TestExecutor:       at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:659)
 E  ( 9562) TestExecutor:       at libcore.reflect.AnnotationAccess.annotationSetToAnnotations(AnnotationAccess.java:633)
 E  ( 9562) TestExecutor:       at libcore.reflect.AnnotationAccess.getDeclaredAnnotations(AnnotationAccess.java:161)
 E  ( 9562) TestExecutor:       at libcore.reflect.AnnotationAccess.getAnnotations(AnnotationAccess.java:111)
 E  ( 9562) TestExecutor:       at java.lang.Class.getAnnotations(Class.java:369)
 E  ( 9562) TestExecutor:       at org.junit.runner.Description.createSuiteDescription(Description.java:124)
 E  ( 9562) TestExecutor:       at org.junit.internal.runners.ErrorReportingRunner.getDescription(ErrorReportingRunner.java:28)
 E  ( 9562) TestExecutor:       at org.junit.runners.Suite.describeChild(Suite.java:123)
 E  ( 9562) TestExecutor:       at org.junit.runners.Suite.describeChild(Suite.java:27)
 E  ( 9562) TestExecutor:       at org.junit.runners.ParentRunner.shouldRun(ParentRunner.java:434)
 E  ( 9562) TestExecutor:       at org.junit.runners.ParentRunner.filter(ParentRunner.java:382)
 E  ( 9562) TestExecutor:       at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
 E  ( 9562) TestExecutor:       at android.support.test.internal.runner.TestRequestBuilder$LenientFilterRequest.getRunner(TestRequestBuilder.java:381)
 E  ( 9562) TestExecutor:       at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
 E  ( 9562) TestExecutor:       at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
 E  ( 9562) TestExecutor:       at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
 E  

Solution

  • -keep class scala.reflect.ScalaSignature {*;}
    

    No **