Android Studio: Testing: Library dependencies that have been compiled using java 8 or above

后端 未结 2 1126
你的背包
你的背包 2021-01-19 16:56

please help. I am having a really horrible time with setting up my testing for android studio.

I have downloaded the calculator example to practice cumcumber code t

相关标签:
2条回答
  • 2021-01-19 17:29

    You have a dependency, unclear which, that is compiled for Java 8 and you have specified Java 7 in your build.

    The error message This is caused by library dependencies that have been compiled using Java 8 or above. is they key here.

    My approach would be to change the Java version to 8. If that didn't do the trick, reduce the problem. That is, start with a new project without dependencies, and code, and add very small parts until I found what caused to error above.

    That is, apply Galls Law:

    "A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over with a working simple system. – John Gall (1975, p.71)"

    https://en.wikipedia.org/wiki/John_Gall_%28author%29

    0 讨论(0)
  • 2021-01-19 17:35

    Ok for any one that is having the same problem. I sussed it! (I think!) its lead on to other problems with the program but at least i have the test running and its communicating with the device and reading through the tests without having paddy. The tests however are coming up with a brand new problem (for another question, another day) New problem if anyone is interested:

    Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
    at least 90 percent of the view's area is displayed to the user.
    

    im guessing that its something to do with not all the buttons not in view (not my design! FYI) so we adjust this tomorrow.

    Now on to the solution(ish)

    https://github.com/cucumber/cucumber-jvm/issues/893: comment from programmerdave on 18 Nov 2015 helped with the gradle setup.

    This brought a whole new bug!

    Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
    > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp/okhttp/pom.properties
        File1: C:\Users\kyleparker\.gradle\caches\modules-2\files-2.1\com.crashlytics.android\crashlytics\1.1.13\e821eafa1bf489a26bdb71f95078c26785b37a1\crashlytics-1.1.13.jar
        File2: C:\Users\kyleparker\.gradle\caches\modules-2\files-2.1\com.squareup.okhttp\okhttp\2.4.0\40340c0748190fe897baf7bffbc1b282734294e5\okhttp-2.4.0.jar
    

    But managed to fix this quite quickly. thanks to these guys https://code.google.com/p/android/issues/detail?id=194980

    Anyway apparently two different issues that created havoc (a day and half).

    Heres the gradle for the Calkulator demo (link in question) - it all feels a bit messy and if anyone has a nice cleaner solution please let me know

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"
    
        defaultConfig {
            applicationId "cucumber.cukeulator"
            minSdkVersion 16
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
    
            testApplicationId "cucumber.cukeulator.test"
            testInstrumentationRunner "cucumber.cukeulator.test.Instrumentation"
        }
    
        packagingOptions {
    
            //these are the ones that fixed it for me
            exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
            exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
    
            //but im not going to  remove my first attempt just in case ;)
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
    
        sourceSets {
            androidTest {
                assets.srcDirs = ['src/androidTest/assets']
            }
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
        androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
    
        androidTestCompile('info.cukes:cucumber-android:1.2.4') {
            exclude module: 'cucumber-jvm-deps'
        }
    
        androidTestCompile('info.cukes:cucumber-picocontainer:1.2.4') {
            exclude module: 'cucumber-jvm-deps'
        }
    
        // androidTestCompile 'com.android.support:support-annotations:23.1.1'
        // androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    
        androidTestCompile 'info.cukes:cucumber-jvm-deps:1.0.3'
    
    }
    

    So all in all it seems to be that jvm-deps......well who knew

    0 讨论(0)
提交回复
热议问题