Simple java modules for android + gradle in Android Studio?

I am working on an Android project in the Android Studio IDE. Is there a way to create tests for some code in an android project that does not require an android virtual machine? I can not mark the "tests" folder as tests and create java files in it. Also, I do not see any parameters related to testing in my module.

Update:

I am trying the following build.gradle:

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    // ...
}

apply plugin: "java"

sourceSets {
    simpleTest {
        java {
            srcDir 'test/java'
        }
        resources {
            srcDir 'test/resources'
        }
        compileClasspath += sourceSets.main.runtimeClasspath
    }
}

task simpleTest(type: Test) {
    description = "Runs simple tests"
    testClassesDir = sourceSets.simpleTest.output.classesDir
    classpath += sourceSets.simpleTest.runtimeClasspath
}

But I get an error message:

12:19:10 Gradle Project 'app' update failed: The java plugin was added, but it is not compatible with Android plugins.

+4
source share
1 answer

Android Gradle http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Simple-build-files, android java ( java-base Android):

: Android. java .

Android , Android- Robolectric Gradle ( Android) Android Studio Gradle.

0

Source: https://habr.com/ru/post/1536389/


All Articles