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

Unresolved reference: appmattus #91

Open
IDisouki2021 opened this issue May 8, 2022 · 3 comments
Open

Unresolved reference: appmattus #91

IDisouki2021 opened this issue May 8, 2022 · 3 comments

Comments

@IDisouki2021
Copy link

IDisouki2021 commented May 8, 2022

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?

@mattmook
Copy link
Member

mattmook commented Jul 6, 2022

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'

@jlbren
Copy link

jlbren commented Jul 8, 2022

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 

@mattmook
Copy link
Member

mattmook commented May 3, 2023

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)

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

3 participants