' transformClassesWithMultidexlistForDebugAndroidTest' android.support.test.runner.AndroidJUnitRunner指定

时间:2016-08-07 12:58:15

标签: android android-studio android-gradle android-espresso

我试图在MultiDex应用程序上运行espresso测试并且因以下错误而失败

  

错误:任务执行失败> :transformClassesWithMultidexlistForDebugAndroidTest&#39 ;.   java.io.IOException:输出jar为空。你有没有指定正确的> ' -keep'选项?

这是我的build.gradle中的相关部分

defaultConfig {
        ...
        //      Enabling multidex support.
        multiDexEnabled true
        dexOptions {
            jumboMode true
        }

        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }

我确实有一个解决方法:

  1. 评论' testInstrumentationRunner'线
  2. 构建测试
  3. 取消注释该行
  4. 运行测试
  5. 这似乎有效,但我需要在我更改测试代码时重新执行此操作,这是一个很大的痛苦。

    可以在网上罚款类似的错误,但对我的情况没有任何特别的解释......

    我正在使用Android studio构建

1 个答案:

答案 0 :(得分:0)

My reputation doesn't allow me to comment, so will write as an answer:

Exactly the same workaround works for me:

  1. Commenting the string with 'testInstumentationRunner'
  2. Building tests. There will be an exception that Instrumentation Runner is not found
  3. Uncomment the string
  4. Run the test

UPD: This solution worked for me, though the question there is about different problem:

Android Espresso not working with Multidex gives "No tests found"