0

In my android studio project i have gradle.build file that looks exactly like

buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
        maven {
          url "https://maven.mozilla.org/maven2/"
        }
    }
    dependencies {

        classpath "com.android.tools.build:gradle:4.1.3"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
      implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}"

    }
}

ext {
    geckoviewChannel = "nightly"
    geckoviewVersion = "85.0.20201121092754"
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

but on running ./gradlew I got error that looks like

A problem occurred evaluating root project 'My Application'.
> Could not get unknown property 'geckoviewChannel' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

I see nothing missing or wrong here. What am I missing here.

Dev-il
  • 157
  • 1
  • 8
  • I guess your dependency is in wrong place. You should write another build.gradle your dependecies which contains kotlin, androidx.core etc. dependencies. For more check this out: https://developer.android.com/studio/build/dependencies – Abdurrahman Oğuzhan Durmaz May 15 '21 at 12:43

2 Answers2

0

Project properties

ext {
    geckoviewChannel = "nightly"
    geckoviewVersion = "85.0.20201121092754"
}

are not visible inside buildscript block which is evaluated first. A potential solution is to move ext block inside buildscript block.

Delta George
  • 2,560
  • 2
  • 17
  • 11
0

This was yet another simple mistake which I managed to solve by practicing individual dependency in module_name/build.gradle as mentioned here. I had stupidly mistaken by ignoring the comment in build.gradle file of project root directory which says

dependencies {
        ...
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

So what i did was reset the build.gradle as it was initially and configure geckoview in module_name/build.gradle.

Dev-il
  • 157
  • 1
  • 8