androidgeckoview

How to fix this error "ERROR: Could not find method compileOptions()" while trying to usee GeckoView?


I'm trying to create an android app using GeckoView, I use the following link as a reference:

https://mozilla.github.io/geckoview/consumer/docs/geckoview-quick-start

I do everything as it is in the example, but I get the following error:

ERROR: Could not find method compileOptions() for arguments [build_5wez28ua38x3wb7sd9hq4qbni$_run_closure4@7323414] on project ':app' of type org.gradle.api.Project.

build.gradle

apply plugin: 'com.android.application'
android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.gc"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
ext {
    geckoviewChannel = "nightly"
    geckoviewVersion = "70.0.20190712095934"
}
repositories {
    maven {
        url "https://maven.mozilla.org/maven2/"
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation "org.mozilla.geckoview:geckoview-${geckoviewChannel}:${geckoviewVersion}"
}

Solution

  • The compileOptions section should be in the android section.

    android {
        compileOptions {
            ...
        }
    }