预验证类中的Android Error Class ref已解决为意外实现

时间:2016-02-11 09:58:38

标签: java android android-studio android-espresso

我在Android Espresso测试中遇到过这个问题。但是这在运行/编译时运行良好。我知道这个错误有几个线程,但我找不到符合我情况的修复程序。我目前正在处理

  

" java.lang.IllegalAccessError:预验证类中的类ref   决定意外实施"。

我已经添加了

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
   exclude group: 'com.android.support', module: 'support-v4'
}

但它还没有奏效。有人可以帮我解决这个问题。感谢。

这是我的依赖

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    /*Android Testing*/
    androidTestCompile 'com.android.support.test:runner:0.3'
    androidTestCompile 'com.android.support.test:rules:0.3'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
    androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.1'
    androidTestCompile 'com.android.support:support-annotations:23.0.1'
    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
        exclude group: 'com.android.support', module: 'support-v4'
    }

    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.android.support:support-v4:23.0.+'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'commons-codec:commons-codec:1.9'

    /*Showcase view for Facebook Intregation*/
    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    /*Showcase view for SwipeRefresh*/
    compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
    /*Multidex*/
    compile 'com.android.support:multidex:1.0.1'
    /*Crashlytics*/
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
}

2 个答案:

答案 0 :(得分:1)

更改

androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
   exclude group: 'com.android.support', module: 'support-v4'
}

  androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }

希望有所帮助

答案 1 :(得分:1)

经过很长一段时间,我找到了一个解决方案,用于gradle 1.5。 我转到Robotium并尝试此代码。 但我认为这也适用于Espresso。 在这里,

androidTestCompile fileTree(dir: 'libs', include:'robotium-solo-5.3.0.jar')
androidTestCompile ('com.android.support:multidex-instrumentation:1.0.1') {
    exclude group: 'com.android.support', module: 'multidex' }

project.configurations.all { config ->
    if (config.name.contains("AndroidTest")) {
        config.resolutionStrategy.eachDependency { details ->
            if (details.requested.name == "multidex") {
                details.useTarget("de.felixschulze.teamcity:teamcity-status-message-helper:1.2")
            }
        }
    }
}