2

I'm trying to include an Android App into a java project using Gradle. The goal is to import the app and write the test on the Java project.

So far my tries had failed and I'm getting this error:

Error:Configuration with name 'default' not found.

The error comes with this configuration (on the line compileOnly project(path: ':app', configuration: "")):

<!-- language: lang-java -->
//java/build.gradle
apply plugin: 'java'

dependencies {
    compileOnly project(path: ':app', configuration: "")
}

//java/settings.gradle
include ':app_test', ':app'
project(':app').projectDir = new File("../androidApp")

Android App gradle

// /androidApp/build.gradle
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "app.com.myapplication"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}


task showConfig {
  doLast {
    println rootProject.configurations
  }
}

Anyway to fix this? or Just have a template how to do it?

  • Is this an option? https://stackoverflow.com/a/27154971/237232 – Dragan Marjanović Mar 12 '18 at 15:12
  • From there I started, but i get the error as well. Error:Configuration with name 'default' not found. – Alexander Soto Cardona Mar 12 '18 at 15:14
  • I wanted to move instrumented tests to a separate module and keep the tested code in original app module: defined new module as an application, use app source sets in new module e.g. java.srcDirs=['../app/src/main/java'] and reused most of app/build.gradle in tests/build.gradle. Tests were failing with "android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching". At this point the approach seemed too hacky and not so robust (duplicated gradle configuration, changing app/build.gradle would break tests module) so I stopped looking into it further – Dragan Marjanović Mar 14 '18 at 14:38

0 Answers0