2

At first - I've been googling to much and use all, what I am found.

My project level build.gradle contains this

at root of file

buildscript {
    ext.kotlin_version = "1.2.31"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        .....
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        .....
    }
}

My module level build.gradle contains this

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 27

    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "iam.thevoid.sudoku"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags ""
            }
        }
        vectorDrawables.useSupportLibrary = true
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }

    dataBinding {
        enabled = true
    }
}


dependencies {
    ..........
    // kotlin
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    .........
}

but i still continue getting the errors during the build

e: \pages\BaseActivity.kt: (16, 9): Unresolved reference: window
e: \pages\GameActivity.kt: (37, 21): Unresolved reference: startActivity
e: \pages\MenuActivity.kt: (30, 21): Unresolved reference: startActivity
e: \util\FileUtil.kt: (19, 31): Unresolved reference: assets
e: \util\FileUtil.kt: (21, 51): Unresolved reference: it
e: \viewmodel\MenuViewModel.kt: (42, 70): Unresolved reference: finish

As you can see - there are simple references, as 'startActivity' or 'finish'. Why does kotlin can not resolve it?

I started get these errors when I've updated something i did not remember. Maybe it was a kotlin plugin version, may be there was an gradle or gradle plugin, but i try downgrade this plugins and not return project in working version.

Can you help?

8
  • Firstly, check your android dependencies in module level build.gradle. Have you updated build tools? Which build tools version do you have installed and which is declared in android block in build.gradle? Commented Apr 17, 2018 at 21:07
  • Open the mentioned files in Android Studio follow the red underlines. Are you extending AppCompatActivity? Did you forget to add dependency on support library? Commented Apr 17, 2018 at 21:08
  • @EugenPechanec all dependencies in project, activity is AppCompatActivity. Fun fact is the all this code works before i've updated gradle file, but when i tried to downgrade all - errors are not gone Commented Apr 17, 2018 at 21:10
  • @jelic98 I've added 'android' block in my Q. As you can see - build tools, sdk versions and other are the newest Commented Apr 17, 2018 at 21:13
  • where is the support library dependency? Commented Apr 17, 2018 at 21:15

1 Answer 1

1

I've found problem! There was dependency, which is break the build. In my case it was the

implementation group: 'com.h2database', name: 'h2', version: '1.3.148'

I've added this for testing Exposed, but i did that at the same time when i updated the build.gradle file.

If you got same erros you can also check your dependencies. Probably one of them break the build.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.