Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Studio 3.1 Canary 9 #64

Open
yunikkk opened this issue Jan 30, 2018 · 28 comments
Open

Android Studio 3.1 Canary 9 #64

yunikkk opened this issue Jan 30, 2018 · 28 comments

Comments

@yunikkk
Copy link

yunikkk commented Jan 30, 2018

I've already created issue in the main spek repo (spekframework/spek#354), seems here is a better place for it.

Spek plugin 0.5.4-studio3.0 fails to run tests.
Trying with sample https://github.com/spekframework/spek-android-example produces
Error running 'org.spekframework.speksample.CalculatorSpec': com.android.tools.idea.gradle.project.model.AndroidModuleModel.getSelectedVariant()Lcom/android/tools/idea/gradle/project/model/ide/android/IdeVariant;
This is very similar to the error which appeared with gradle sync-s in Studio Canary 3, https://stackoverflow.com/questions/47290290/android-studio-3-1-canary-3-gradle-sync-failed.

@yunikkk
Copy link
Author

yunikkk commented Jan 30, 2018

Well, I managed to update Kotlin and Gradle plugin's version, assembled plugin then works with Canary, too.

@raniejade
Copy link
Owner

@yunikkk so just recompiling the plugin fixed it?

@yunikkk
Copy link
Author

yunikkk commented Feb 1, 2018

Basically, yes.
It worked with kotlinVersion=1.2.20 and plugin "org.jetbrains.kotlin:$kotlinVersion-release-Studio3.1-1.

@julioyg
Copy link

julioyg commented Feb 5, 2018

Hi, there, so, what's the fix? is it going to be any update?

Thanks

@raniejade
Copy link
Owner

raniejade commented Feb 5, 2018 via email

@julioyg
Copy link

julioyg commented Feb 5, 2018

makes sense, would it be possible then, to have some instructions on how to compile it in the same way @yunikkk did, so anyone who wants to use the preview version of AS can use it?

@raniejade
Copy link
Owner

./gradlew clean plugin-studio3.0:buildPlugin should do it, the plugin will be at plugin-studio3.0/build/distributions.

@radityagumay
Copy link

@raniejade HI, i just update AS 3.1.0. and suddenly i cannot run spek by using IDE. but still run when using command line. how to fix that?

@raniejade
Copy link
Owner

I'm trying out a fix locally, but the jcenter outage is blocking me. Hopefully, this gets fixed soon.

@raniejade
Copy link
Owner

@radityagumay @julioyg @yunikkk can you guys test this build out: https://drive.google.com/file/d/11BT-2alz6C6XxqZCAqggje1l1HvNxarl/view?usp=sharing. It works for me, let me know if there are issues.

@julioyg
Copy link

julioyg commented Mar 28, 2018

works for me, Thanks! :) :shipit:

@radityagumay
Copy link

@raniejade hi, great.i will check that out and info to you soon!

@almozavr
Copy link

I've tried the latest plugin from the link on above, but it fails with Test framework quit unexpectedly. Could anyone help to get the logs out?
screenshot

My config is mannodermaus/android-junit5 + spec which is ok for ./gradlew test
config screenshot

@almozavr
Copy link

OK, my problem was testRuntimeOnly(deps.test.spek.engine) – it should be testCompileOnly(deps.test.spek.engine)

@radityagumay
Copy link

radityagumay commented Mar 28, 2018

@raniejade I got different error

Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/radityagumay/AndroidStudioProjects/Foo/GreateApp/app/libs/junit-platform-launcher-1.0.1.jar

@radityagumay
Copy link

@almozavr can you share you full config?

I use AS 3.1.0
classpath 'com.android.tools.build:gradle:3.1.0' ,
ext.kotlinVersion = '1.2.31'

I got
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/radityagumay/AndroidStudioProjects/Foo/GreateApp/app/libs/junit-platform-launcher-1.0.1.jar

@almozavr
Copy link

@radityagumay here it is

Gradle wrapper:

4.6

Dependencies versions

versions.android_gradle_plugin = '3.1.0'
//============================================== KOTLIN ============================================
versions.kotlin = '1.2.31'
versions.kotlin_runtime = "${versions.kotlin}-release-Studio3.1-1"
def kotlin = [:]
kotlin.stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jre7:$versions.kotlin"
kotlin.reflect = "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin"
kotlin.test = "org.jetbrains.kotlin:kotlin-test:$versions.kotlin"
kotlin.gradle_plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
//============================================ TESTS ===============================================
def test = [:]
test.spek = [:]
test.spek.api = 'org.jetbrains.spek:spek-api:1.1.5'
test.spek.engine = 'org.jetbrains.spek:spek-junit-platform-engine:1.1.5'

Buildscript Dependencies

classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.31"

app's build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: "de.mannodermaus.android-junit5"

android {
    compileSdkVersion build_versions.compile_sdk
    defaultConfig {
        applicationId "com.vodolazskiy.treellogin"
        minSdkVersion build_versions.min_sdk
        targetSdkVersion build_versions.target_sdk
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        encoding "UTF-8"
    }
    sourceSets {
        main.java.srcDirs += "src/main/kotlin"
        test.java.srcDirs += "src/test/kotlin"
    }
    testOptions {
        junitPlatform {
            filters {
                engines {
                    include "spek"
                }
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //support
    implementation deps.support.appcompat
    implementation deps.support.annotations
    implementation deps.support.design

    //kotlin
    implementation deps.kotlin.stdlib

    //rx
    implementation deps.rx.android
    implementation deps.rx.java
    implementation deps.rx.rxbinding

    //mosby
    implementation deps.mosby.core
    implementation deps.mosby.queuing

    //kodein
    implementation deps.kodein.lib
    implementation deps.kodein.android

    //conductor
    implementation deps.conductor.lib

    //tests
    testImplementation(deps.test.spek.api) {
        exclude group: 'org.jetbrains.kotlin'
    }
    testCompileOnly(deps.test.spek.engine) {
        exclude group: "org.junit.platform"
        exclude group: "org.jetbrains.kotlin"
    }
    testImplementation junit5.unitTests()
    testCompileOnly junit5.unitTestsRuntime()
    testImplementation deps.kotlin.reflect
    testImplementation deps.kotlin.test

}

@raniejade
Copy link
Owner

Perhaps, try updating junit-platform?

@radityagumay
Copy link

radityagumay commented Mar 29, 2018

@raniejade i've been update like @almozavr answer but, still wont works.

screen shot 2018-03-29 at 11 34 12 am

^ run icon in left is missing. and spek class is like not being used by someone. but, when i use jUnit, its works.

screen shot 2018-03-29 at 11 48 30 am

screen shot 2018-03-29 at 11 48 12 am

@raniejade see the diff between generate kotlin-classes, i did ./gradlew testDebugUnitTest jacocoDebugTestReport

in spek we havent implementation detail of concrete classes. but, in junit had.

@raniejade for inject the lib that you share, this just copying to app/libs right? is any config should i do?

here's my configuration

================== buildscript ====================

`buildscript {
ext.kotlinVersion = '1.2.31'
repositories {
jcenter()
maven { url "http://dl.bintray.com/jetbrains/spek" }
google()
}
dependencies {
classpath 'org.ow2.asm:asm:6.0'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.1'
classpath 'org.jacoco:org.jacoco.core:0.8.0'
classpath 'com.android.tools.build:gradle:3.1.0'

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion"

    classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.3"
    classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.31"
}

}`

============= build.gradle ===============

`
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'org.sonarqube'

apply from: "$rootDir/coverage.gradle"

// junit5 doesn't support android projects out of the box
apply plugin: "de.mannodermaus.android-junit5"

android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion

defaultConfig {
    ...
}

lintOptions {
    abortOnError false
}

signingConfigs {
    ..
}

buildTypes {
    debug {
        testCoverageEnabled true
    }
}

testOptions {
    execution 'ANDROID_TEST_ORCHESTRATOR'
    animationsDisabled true

    unitTests.all {
        jacoco {
            includeNoLocationClasses = true
        }
    }

    junitPlatform {
        filters {
            engines {
                include "spek"
            }
        }
    }
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    test.java.srcDirs += 'src/test/kotlin'
    androidTest.java.srcDirs += 'src/androidTest/kotlin'
}

}

dependencies {
testImplementation(testLibraries.spek) {
exclude group: "org.jetbrains.kotlin"
}
testImplementation(testLibraries.spekEngine) {
exclude group: "org.junit.platform"
exclude group: "org.jetbrains.kotlin"
}
testImplementation testLibraries.junitEngine
testImplementation testLibraries.kotlinReflect

testImplementation testLibraries.junit
testImplementation testLibraries.mockitoCore

testImplementation testLibraries.assertj
testImplementation testLibraries.assertk

testImplementation(testLibraries.nhaarman) {
    exclude group: 'org.jetbrains.kotlin'
}

androidTestImplementation testLibraries.mockitoCore
androidTestImplementation testLibraries.dexMakerMockito
androidTestImplementation(testSupportDependencies.espressoCore) {
    exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation(testSupportDependencies.espressoIntents) {
    exclude group: 'com.android.support', module: 'support-annotations'
}
testImplementation testLibraries.mockWebServer

//https://developer.android.com/topic/libraries/testing-support-library/release-notes.html#espresso_302-alpha1_runner_102-alpha1_rules_102-alpha1_androidtestorchestrator_102-alpha1_2017-12-05
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'

androidTestUtil 'com.android.support.test:orchestrator:1.0.1'

}
`

@raniejade @almozavr

@raniejade
Copy link
Owner

@radityagumay that means the plugin is not loaded. Can you guys dump what versions of JUnit Platform are you using? The plugin works with this project: https://github.com/spekframework/spek-android-example

@almozavr
Copy link

almozavr commented Mar 29, 2018

@radityagumay you're missing

testImplementation junit5.unitTests()
testCompileOnly junit5.unitTestsRuntime()

Note, it's not a custom dependency, but a function from de.mannodermaus.android-junit5 plugin.
Also, as I understand it completely swaps testImplementation testLibraries.junitEngine

@raniejade
Copy link
Owner

@almozavr is it working for you? or is there a dexing error?

@raniejade
Copy link
Owner

Hey guys, is anyone still experiencing an error? Otherwise I'm going to release the build this weekend.

@yunikkk
Copy link
Author

yunikkk commented Apr 4, 2018

@raniejade works for me, too. AS 3.1 RC3.

@radityagumay
Copy link

radityagumay commented Apr 4, 2018

didn't works for me, and several my friends that use AS 3.1 stable @raniejade.

screen shot 2018-04-04 at 7 34 34 pm

@yunikkk
Copy link
Author

yunikkk commented Apr 4, 2018

Hmm, just updated to AS 3.1, still works fine here @radityagumay . Guess its smth with your project settings.

@castorflex
Copy link

@raniejade Your fix worked for me too (AS 3.1), thanks :)

@almozavr
Copy link

almozavr commented Apr 6, 2018

@raniejade plugin works pretty fine 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants