kotlinfixture icon indicating copy to clipboard operation
kotlinfixture copied to clipboard

Unresolved reference: appmattus

Open IDisouki2021 opened this issue 2 years ago • 3 comments

Hello,

First, thank you for the great library.

Cannot import import com.appmattus.kotlinfixture.kotlinFixture error Unresolved reference: appmattus\

build.gradle(My Application) file: // Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
    id 'com.android.application' version '7.1.3' apply false
    id 'com.android.library' version '7.1.3' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(app module) file:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.4.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.4.2'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    testImplementation 'com.appmattus.fixture:fixture:1.5.31'
}

settings.gradle file:

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
    }
}
rootProject.name = "My Application"
include ':app'

ExampleUnitTest file:

package com.example.myapplication

import org.junit.Test

import org.junit.Assert.*
import com.appmattus.kotlinfixture.kotlinFixture // Unresolved reference: appmattus

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {

    private val fixture = kotlinFixture()

    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }
}

Should I use kts to get it to work?

IDisouki2021 avatar May 08 '22 12:05 IDisouki2021

You shouldn't need kts to get this to work, it looks like you're just using the wrong version number.

Try:

    testImplementation 'com.appmattus.fixture:fixture:1.2.0'

mattmook avatar Jul 06 '22 07:07 mattmook

I'm also experiencing this exact issue under a kts gradle build and using the latest version

    testImplementation("com.appmattus.fixture:fixture:1.2.0")
import com.appmattus.kotlinfixture.kotlinFixture // Unresolved reference: appmattus 

jlbren avatar Jul 08 '22 21:07 jlbren

I used the files attached but have been unable to reproduce; well that is unless I have a mismatch between the type of test (unit test in src/test vs instrumentation in src/androidTest) and the dependency definition (testImplementation vs androidTestImplementation)

mattmook avatar May 03 '23 22:05 mattmook